Struct AttributeTable

Source
pub struct AttributeTable<'d, M: RawMutex, const MAX: usize> { /* private fields */ }
Expand description

A table of attributes.

Implementations§

Source§

impl<'d, M: RawMutex, const MAX: usize> AttributeTable<'d, M, MAX>

Source

pub fn new() -> Self

Create a new GATT table.

Source

pub fn add_service( &mut self, service: Service, ) -> ServiceBuilder<'_, 'd, M, MAX>

Add a service to the attribute table (group of characteristics)

Source

pub fn set<T: AttributeHandle>( &self, attribute_handle: &T, input: &T::Value, ) -> Result<(), Error>

Set the value of a characteristic

The provided data must exactly match the size of the storage for the characteristic, otherwise this function will panic.

If the characteristic for the handle cannot be found, or the shape of the data does not match the type of the characterstic, an error is returned

Source

pub fn get<T: AttributeHandle<Value = V>, V: FromGatt>( &self, attribute_handle: &T, ) -> Result<T::Value, Error>

Read the value of the characteristic and pass the value to the provided closure.

The return value of the closure is returned in this function and is assumed to be infallible.

If the characteristic for the handle cannot be found, an error is returned.

Source

pub fn find_characteristic_by_value_handle<T: AsGatt>( &self, handle: u16, ) -> Result<Characteristic<T>, Error>

Return the characteristic which corresponds to the supplied value handle

If no characteristic corresponding to the given value handle was found, returns an error

Trait Implementations§

Source§

impl<M: RawMutex, const MAX: usize> Default for AttributeTable<'_, M, MAX>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'d, M, const MAX: usize> !Freeze for AttributeTable<'d, M, MAX>

§

impl<'d, M, const MAX: usize> !RefUnwindSafe for AttributeTable<'d, M, MAX>

§

impl<'d, M, const MAX: usize> Send for AttributeTable<'d, M, MAX>
where M: Send,

§

impl<'d, M, const MAX: usize> Sync for AttributeTable<'d, M, MAX>
where M: Sync,

§

impl<'d, M, const MAX: usize> Unpin for AttributeTable<'d, M, MAX>
where M: Unpin,

§

impl<'d, M, const MAX: usize> !UnwindSafe for AttributeTable<'d, M, MAX>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.