pub trait Client {
type Event;
// Required methods
fn on_hvx(
&self,
conn: &Connection,
type_: HvxType,
handle: u16,
data: &[u8],
) -> Option<Self::Event>;
fn uuid() -> Uuid;
fn new_undiscovered(conn: Connection) -> Self;
fn discovered_characteristic(
&mut self,
characteristic: &Characteristic,
descriptors: &[Descriptor],
);
fn discovery_complete(&mut self) -> Result<(), DiscoverError>;
}
Expand description
Trait for implementing GATT clients.
Required Associated Types§
Required Methods§
Sourcefn on_hvx(
&self,
conn: &Connection,
type_: HvxType,
handle: u16,
data: &[u8],
) -> Option<Self::Event>
fn on_hvx( &self, conn: &Connection, type_: HvxType, handle: u16, data: &[u8], ) -> Option<Self::Event>
Handles notification and indication events from the GATT server.
Sourcefn uuid() -> Uuid
fn uuid() -> Uuid
Get the UUID of the GATT service. This is used by discover
to search for the
service in the GATT server.
Sourcefn new_undiscovered(conn: Connection) -> Self
fn new_undiscovered(conn: Connection) -> Self
Create a new instance in a “not-yet-discovered” state.
Sourcefn discovered_characteristic(
&mut self,
characteristic: &Characteristic,
descriptors: &[Descriptor],
)
fn discovered_characteristic( &mut self, characteristic: &Characteristic, descriptors: &[Descriptor], )
Called by discover
for every discovered characteristic. Implementations must
check if they’re interested in the UUID of the characteristic, and save their
handles if needed.
Sourcefn discovery_complete(&mut self) -> Result<(), DiscoverError>
fn discovery_complete(&mut self) -> Result<(), DiscoverError>
Called by discover
at the end of the discovery procedure. Implementations must check
that all required characteristics have been discovered, and return DiscoverError::ServiceIncomplete
otherwise.
If no error is returned, this instance is considered ready to use and is returned to
the caller of discover
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.