Trait Peripheral

Source
pub trait Peripheral:
    Send
    + Sync
    + Clone
    + Debug {
Show 16 methods // Required methods fn id(&self) -> PeripheralId; fn address(&self) -> BDAddr; fn properties<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<PeripheralProperties>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn services(&self) -> BTreeSet<Service>; fn is_connected<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn discover_services<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, data: &'life2 [u8], write_type: WriteType, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn read<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn unsubscribe<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn notifications<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = ValueNotification> + Send>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn write_descriptor<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, descriptor: &'life1 Descriptor, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn read_descriptor<'life0, 'life1, 'async_trait>( &'life0 self, descriptor: &'life1 Descriptor, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided method fn characteristics(&self) -> BTreeSet<Characteristic> { ... }
}
Expand description

Peripheral is the device that you would like to communicate with (the “server” of BLE). This struct contains both the current state of the device (its properties, characteristics, etc.) as well as functions for communication.

Required Methods§

Source

fn id(&self) -> PeripheralId

Returns the unique identifier of the peripheral.

Source

fn address(&self) -> BDAddr

Returns the MAC address of the peripheral.

Source

fn properties<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<PeripheralProperties>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the set of properties associated with the peripheral. These may be updated over time as additional advertising reports are received.

Source

fn services(&self) -> BTreeSet<Service>

The set of services we’ve discovered for this device. This will be empty until discover_services is called.

Source

fn is_connected<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns true iff we are currently connected to the device.

Source

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a connection to the device. If this method returns Ok there has been successful connection. Note that peripherals allow only one connection at a time. Operations that attempt to communicate with a device will fail until it is connected.

Source

fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Terminates a connection to the device.

Source

fn discover_services<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Discovers all services for the device, including their characteristics.

Source

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, data: &'life2 [u8], write_type: WriteType, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write some data to the characteristic. Returns an error if the write couldn’t be sent or (in the case of a write-with-response) if the device returns an error.

Source

fn read<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sends a read request to the device. Returns either an error if the request was not accepted or the response from the device.

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enables either notify or indicate (depending on support) for the specified characteristic.

Source

fn unsubscribe<'life0, 'life1, 'async_trait>( &'life0 self, characteristic: &'life1 Characteristic, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Disables either notify or indicate (depending on support) for the specified characteristic.

Source

fn notifications<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = ValueNotification> + Send>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a stream of notifications for characteristic value updates. The stream will receive a notification when a value notification or indication is received from the device. The stream will remain valid across connections and can be queried before any connection is made.

Source

fn write_descriptor<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, descriptor: &'life1 Descriptor, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write some data to the descriptor. Returns an error if the write couldn’t be sent or (in the case of a write-with-response) if the device returns an error.

Source

fn read_descriptor<'life0, 'life1, 'async_trait>( &'life0 self, descriptor: &'life1 Descriptor, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sends a read descriptor request to the device. Returns either an error if the request was not accepted or the response from the device.

Provided Methods§

Source

fn characteristics(&self) -> BTreeSet<Characteristic>

The set of characteristics we’ve discovered for this device. This will be empty until discover_services is called.

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§