diff options
author | 2025-02-07 18:28:56 +0000 | |
---|---|---|
committer | 2025-02-10 22:36:34 +0000 | |
commit | 69f67e7ee21a67868f16881c82ab9425bbe3e43c (patch) | |
tree | 0f3cf7272006bb11f5235f4efe3e71c4f9c523c1 | |
parent | 52b4e75352b247ed97af76972579a2b472d07f73 (diff) |
Add bitwise operators to declare_binder_enum
Test: atest aidl_integration_test
Bug: 393455995
Change-Id: Ie8621848062185fd5c236272f8ee04b21b3f1d10
-rw-r--r-- | libs/binder/rust/src/binder.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/binder/rust/src/binder.rs b/libs/binder/rust/src/binder.rs index 8c0501ba2f..6a8a69843a 100644 --- a/libs/binder/rust/src/binder.rs +++ b/libs/binder/rust/src/binder.rs @@ -1201,5 +1201,45 @@ macro_rules! declare_binder_enum { Ok(v.map(|v| v.into_iter().map(Self).collect())) } } + + impl std::ops::BitOr for $enum { + type Output = Self; + fn bitor(self, rhs: Self) -> Self { + Self(self.0 | rhs.0) + } + } + + impl std::ops::BitOrAssign for $enum { + fn bitor_assign(&mut self, rhs: Self) { + self.0 = self.0 | rhs.0; + } + } + + impl std::ops::BitAnd for $enum { + type Output = Self; + fn bitand(self, rhs: Self) -> Self { + Self(self.0 & rhs.0) + } + } + + impl std::ops::BitAndAssign for $enum { + fn bitand_assign(&mut self, rhs: Self) { + self.0 = self.0 & rhs.0; + } + } + + impl std::ops::BitXor for $enum { + type Output = Self; + fn bitxor(self, rhs: Self) -> Self { + Self(self.0 ^ rhs.0) + } + } + + impl std::ops::BitXorAssign for $enum { + fn bitxor_assign(&mut self, rhs: Self) { + self.0 = self.0 ^ rhs.0; + } + } + }; } |