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§
Sourcefn id(&self) -> PeripheralId
fn id(&self) -> PeripheralId
Returns the unique identifier of the peripheral.
Sourcefn 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 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.
Sourcefn services(&self) -> BTreeSet<Service>
fn services(&self) -> BTreeSet<Service>
The set of services we’ve discovered for this device. This will be empty until
discover_services
is called.
Sourcefn 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 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.
Sourcefn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 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,
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.
Sourcefn disconnect<'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,
Terminates a connection to the device.
Sourcefn discover_services<'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,
Discovers all services for the device, including their characteristics.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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§
Sourcefn characteristics(&self) -> BTreeSet<Characteristic>
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.