trouble-host

Crates

git

Versions

default

Flavors

Struct Characteristic

Source
pub struct Characteristic<T: AsGatt> {
    pub cccd_handle: Option<u16>,
    pub handle: u16,
    /* private fields */
}
Expand description

A characteristic in the attribute table.

Fields§

§cccd_handle: Option<u16>

Handle value assigned to the Client Characteristic Configuration Descriptor (if any)

§handle: u16

Handle value assigned to this characteristic when it is added to the Gatt Attribute Table

Implementations§

Source§

impl<T: FromGatt> Characteristic<T>

Source

pub async fn notify( &self, connection: &GattConnection<'_, '_>, value: &T, ) -> Result<(), Error>

Write a value to a characteristic, and notify a connection with the new value of the characteristic.

If the provided connection has not subscribed for this characteristic, it will not be notified.

If the characteristic does not support notifications, an error is returned.

Source

pub fn set<M: RawMutex, const AT: usize, const CT: usize, const CN: usize>( &self, server: &AttributeServer<'_, M, AT, CT, CN>, value: &T, ) -> Result<(), Error>

Set the value of the characteristic in the provided attribute server.

Source

pub fn get<M: RawMutex, const AT: usize, const CT: usize, const CN: usize>( &self, server: &AttributeServer<'_, M, AT, CT, CN>, ) -> Result<T, Error>

Read the value of the characteristic.

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

Source

pub fn cccd_handle(&self) -> Option<CharacteristicPropertiesHandle>

Returns the attribute handle for the characteristic’s properties (if available)

Trait Implementations§

Source§

impl<T: AsGatt> AttributeHandle for Characteristic<T>

Source§

type Value = T

The data type which the attribute contains
Source§

fn handle(&self) -> u16

Returns the attribute’s handle
Source§

impl<T: Clone + AsGatt> Clone for Characteristic<T>

Source§

fn clone(&self) -> Characteristic<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + AsGatt> Debug for Characteristic<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: AsGatt> Format for Characteristic<T>

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
Source§

impl<T: PartialEq + AsGatt> PartialEq for Characteristic<T>

Source§

fn eq(&self, other: &Characteristic<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Copy + AsGatt> Copy for Characteristic<T>

Source§

impl<T: AsGatt> StructuralPartialEq for Characteristic<T>

Auto Trait Implementations§

§

impl<T> Freeze for Characteristic<T>

§

impl<T> RefUnwindSafe for Characteristic<T>
where T: RefUnwindSafe,

§

impl<T> Send for Characteristic<T>
where T: Send,

§

impl<T> Sync for Characteristic<T>
where T: Sync,

§

impl<T> Unpin for Characteristic<T>
where T: Unpin,

§

impl<T> UnwindSafe for Characteristic<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.