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>
impl<T: FromGatt> Characteristic<T>
Sourcepub async fn notify(
&self,
connection: &GattConnection<'_, '_>,
value: &T,
) -> Result<(), Error>
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.
Sourcepub fn set<M: RawMutex, const AT: usize, const CT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, AT, CT, CN>,
value: &T,
) -> Result<(), Error>
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.
Sourcepub fn get<M: RawMutex, const AT: usize, const CT: usize, const CN: usize>(
&self,
server: &AttributeServer<'_, M, AT, CT, CN>,
) -> Result<T, Error>
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.
Sourcepub fn cccd_handle(&self) -> Option<CharacteristicPropertiesHandle>
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>
impl<T: AsGatt> AttributeHandle for Characteristic<T>
Source§impl<T: Clone + AsGatt> Clone for Characteristic<T>
impl<T: Clone + AsGatt> Clone for Characteristic<T>
Source§fn clone(&self) -> Characteristic<T>
fn clone(&self) -> Characteristic<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: AsGatt> Format for Characteristic<T>
impl<T: AsGatt> Format for Characteristic<T>
impl<T: Copy + AsGatt> Copy for Characteristic<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more