Struct Peripheral

Source
pub struct Peripheral { /* private fields */ }
Expand description

Implementation of api::Peripheral.

Trait Implementations§

Source§

impl Clone for Peripheral

Source§

fn clone(&self) -> Peripheral

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Peripheral

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Peripheral for Peripheral

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.
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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.