diff options
| author | 2021-12-16 06:14:10 +0000 | |
|---|---|---|
| committer | 2021-12-16 06:14:10 +0000 | |
| commit | becba19da38b002c31d9c414b36f7776dc7a4d2c (patch) | |
| tree | 8b2afee3978e246beadd9a92951e893028c86bbe | |
| parent | fa7884df10ee376a8b736166753a6666e09190d5 (diff) | |
| parent | a43a2fab987a3138ff8d02cd6b3a742ddc3f9dcc (diff) | |
libbinder_rs: PartialEq for ParcelFileDescriptor am: bbfe6b1232 am: 9040251850 am: a43a2fab98
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1924237
Change-Id: I929d433c922cc8cb1537fd0e47401f50fdae3399
| -rw-r--r-- | libs/binder/rust/src/parcel/file_descriptor.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/binder/rust/src/parcel/file_descriptor.rs b/libs/binder/rust/src/parcel/file_descriptor.rs index b0dea945e0..4d3d59afb0 100644 --- a/libs/binder/rust/src/parcel/file_descriptor.rs +++ b/libs/binder/rust/src/parcel/file_descriptor.rs @@ -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(); |