From 5be62cc1cfe5f92a7b22aea1fab860bb7ee3c314 Mon Sep 17 00:00:00 2001 From: Pete Kubiak Date: Wed, 26 Feb 2025 15:30:40 +0000 Subject: [PATCH] Replace ToGatt references with AsGatt --- host/src/attribute.rs | 12 ++++++------ host/src/types/gatt_traits.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/host/src/attribute.rs b/host/src/attribute.rs index c9570fc6..c3391b2d 100644 --- a/host/src/attribute.rs +++ b/host/src/attribute.rs @@ -474,13 +474,13 @@ impl<'d, M: RawMutex, const MAX: usize> AttributeTable<'d, M, MAX> { /// A type which holds a handle to an attribute in the attribute table pub trait AttributeHandle { /// The data type which the attribute contains - type Value: ToGatt; + type Value: AsGatt; /// Returns the attribute's handle fn handle(&self) -> u16; } -impl AttributeHandle for Characteristic { +impl AttributeHandle for Characteristic { type Value = T; fn handle(&self) -> u16 { @@ -725,7 +725,7 @@ impl<'d, T: AsGatt, M: RawMutex, const MAX: usize> CharacteristicBuilder<'_, 'd, } /// Add a characteristic descriptor for this characteristic. - pub fn add_descriptor>( + pub fn add_descriptor>( &mut self, uuid: U, props: &[CharacteristicProp], @@ -746,7 +746,7 @@ impl<'d, T: AsGatt, M: RawMutex, const MAX: usize> CharacteristicBuilder<'_, 'd, } /// Add a read only characteristic descriptor for this characteristic. - pub fn add_descriptor_ro>(&mut self, uuid: U, data: &'d [u8]) -> Descriptor
{ + pub fn add_descriptor_ro>(&mut self, uuid: U, data: &'d [u8]) -> Descriptor
{ let props = [CharacteristicProp::Read].into(); self.add_descriptor_internal(uuid.into(), props, AttributeData::ReadOnlyData { props, value: data }) } @@ -760,12 +760,12 @@ impl<'d, T: AsGatt, M: RawMutex, const MAX: usize> CharacteristicBuilder<'_, 'd, /// Characteristic descriptor handle. #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[derive(Clone, Copy, Debug)] -pub struct Descriptor { +pub struct Descriptor { pub(crate) handle: u16, phantom: PhantomData, } -impl AttributeHandle for Descriptor { +impl AttributeHandle for Descriptor { type Value = T; fn handle(&self) -> u16 { diff --git a/host/src/types/gatt_traits.rs b/host/src/types/gatt_traits.rs index c39ec554..658441f1 100644 --- a/host/src/types/gatt_traits.rs +++ b/host/src/types/gatt_traits.rs @@ -179,7 +179,7 @@ impl AsGatt for &'static str { } } -impl ToGatt for &'static [u8] { +impl AsGatt for &'static [u8] { const MIN_SIZE: usize = 0; const MAX_SIZE: usize = usize::MAX; @@ -188,7 +188,7 @@ impl ToGatt for &'static [u8] { } } -impl ToGatt for crate::types::uuid::Uuid { +impl AsGatt for crate::types::uuid::Uuid { const MIN_SIZE: usize = 2; const MAX_SIZE: usize = 16;