Skip to content

Commit

Permalink
Replace ToGatt references with AsGatt
Browse files Browse the repository at this point in the history
  • Loading branch information
petekubiak committed Feb 26, 2025
1 parent 3e4564a commit 5be62cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions host/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: ToGatt> AttributeHandle for Characteristic<T> {
impl<T: AsGatt> AttributeHandle for Characteristic<T> {
type Value = T;

fn handle(&self) -> u16 {
Expand Down Expand Up @@ -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<DT: ToGatt, U: Into<Uuid>>(
pub fn add_descriptor<DT: AsGatt, U: Into<Uuid>>(
&mut self,
uuid: U,
props: &[CharacteristicProp],
Expand All @@ -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<DT: ToGatt, U: Into<Uuid>>(&mut self, uuid: U, data: &'d [u8]) -> Descriptor<DT> {
pub fn add_descriptor_ro<DT: AsGatt, U: Into<Uuid>>(&mut self, uuid: U, data: &'d [u8]) -> Descriptor<DT> {
let props = [CharacteristicProp::Read].into();
self.add_descriptor_internal(uuid.into(), props, AttributeData::ReadOnlyData { props, value: data })
}
Expand All @@ -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<T: ToGatt> {
pub struct Descriptor<T: AsGatt> {
pub(crate) handle: u16,
phantom: PhantomData<T>,
}

impl<T: ToGatt> AttributeHandle for Descriptor<T> {
impl<T: AsGatt> AttributeHandle for Descriptor<T> {
type Value = T;

fn handle(&self) -> u16 {
Expand Down
4 changes: 2 additions & 2 deletions host/src/types/gatt_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 5be62cc

Please sign in to comment.