trouble-host

Crates

git

Versions

default

Flavors

Trait FixedGattValue

Source
pub trait FixedGattValue: FromGatt {
    const SIZE: usize;

    // Required methods
    fn from_gatt(data: &[u8]) -> Result<Self, FromGattError>;
    fn as_gatt(&self) -> &[u8];
}
Expand description

Trait to allow conversion of a fixed size type to and from a byte slice

Required Associated Constants§

Source

const SIZE: usize

Size of the type in bytes

Required Methods§

Source

fn from_gatt(data: &[u8]) -> Result<Self, FromGattError>

Converts from gatt bytes. Must return FromGattError::InvalidLength if data.len != Self::SIZE

Source

fn as_gatt(&self) -> &[u8]

Converts to gatt bytes. Must return a slice of len Self::SIZE

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.

Implementations on Foreign Types§

Source§

impl FixedGattValue for bool

Source§

const SIZE: usize = 1usize

Source§

fn from_gatt(data: &[u8]) -> Result<Self, FromGattError>

Source§

fn as_gatt(&self) -> &[u8]

Implementors§