Trait FromCharacteristic

Source
pub trait FromCharacteristic: Sized {
    const UUID: Uuid;

    // Required methods
    fn from_chr(
        characteristic: Characteristic,
        value: &[u8],
    ) -> Result<Self, Error>;
    fn update(&mut self, new_value: &[u8]) -> Result<&mut Self, Error>;

    // Provided method
    fn try_read<T: GattTypes>(
        characteristic: Characteristic,
        service: &T::PeerService,
    ) -> impl Future<Output = Result<Self, Error>> { ... }
}
Expand description

Implement when a type can be deserialized from a characteristic value.

Required Associated Constants§

Required Methods§

Source

fn from_chr(characteristic: Characteristic, value: &[u8]) -> Result<Self, Error>

Create this type from a Characteristic and an initial value.

Source

fn update(&mut self, new_value: &[u8]) -> Result<&mut Self, Error>

Attempt to update the type when supplied with the new_value, which may or may not be the complete value.

Provided Methods§

Source

fn try_read<T: GattTypes>( characteristic: Characteristic, service: &T::PeerService, ) -> impl Future<Output = Result<Self, Error>>

Attempt to read a characteristic if it matches the provided characteristic UUID.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§