Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bbfe6b12 authored by Jooyung Han's avatar Jooyung Han
Browse files

libbinder_rs: PartialEq for ParcelFileDescriptor

NDK's ScopedFileDescriptor can be checked for equality. Add impl for
PartialEq for ParcelFileDescriptor.

With this, @RustDerive(PartialEq=true) works when the parcelable has
a ParcelFileDescriptor field.

Bug: n/a
Test: aidl_integration_test
Change-Id: I94d064db46f3e1bf43180e4fee9cf2a0487980e7
parent 1f5c2091
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -60,6 +60,16 @@ impl IntoRawFd for ParcelFileDescriptor {
    }
}

impl PartialEq for ParcelFileDescriptor {
    // Since ParcelFileDescriptors own the FD, if this function ever returns true (and it is used to
    // compare two different objects), then it would imply that an FD is double-owned.
    fn eq(&self, other: &Self) -> bool {
        self.as_raw_fd() == other.as_raw_fd()
    }
}

impl Eq for ParcelFileDescriptor {}

impl Serialize for ParcelFileDescriptor {
    fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<()> {
        let fd = self.0.as_raw_fd();