rust/bt-gatt: Fix test
Fix test by properly converting single CharacteristicProperty to
CharacteristicProperties struct.
Change-Id: Id5363ddda379b7e8e8fef74951be4a7284c91925
Reviewed-on: https://bluetooth-review.git.corp.google.com/c/bluetooth/+/1960
Reviewed-by: Marie Janssen <jamuraa@google.com>
diff --git a/rust/bt-gatt/src/types.rs b/rust/bt-gatt/src/types.rs
index 0e7ada4..3e3dc06 100644
--- a/rust/bt-gatt/src/types.rs
+++ b/rust/bt-gatt/src/types.rs
@@ -218,9 +218,38 @@
WritableAuxiliaries = 0x200,
}
+impl std::ops::BitOr for CharacteristicProperty {
+ type Output = CharacteristicProperties;
+
+ fn bitor(self, rhs: Self) -> Self::Output {
+ CharacteristicProperties(vec![self, rhs])
+ }
+}
+
#[derive(Default, Debug, Clone)]
pub struct CharacteristicProperties(pub Vec<CharacteristicProperty>);
+impl From<CharacteristicProperty> for CharacteristicProperties {
+ fn from(value: CharacteristicProperty) -> Self {
+ Self(vec![value])
+ }
+}
+
+impl FromIterator<CharacteristicProperty> for CharacteristicProperties {
+ fn from_iter<T: IntoIterator<Item = CharacteristicProperty>>(iter: T) -> Self {
+ Self(iter.into_iter().collect())
+ }
+}
+
+impl std::ops::BitOr<CharacteristicProperty> for CharacteristicProperties {
+ type Output = Self;
+
+ fn bitor(mut self, rhs: CharacteristicProperty) -> Self::Output {
+ self.0.push(rhs);
+ self
+ }
+}
+
#[derive(Debug, Clone, Copy, Default)]
pub struct SecurityLevels {
/// Encryption is required / provided