Skip to main content

BluestConnection

Struct BluestConnection 

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

A GattConnection over a connected bluest Device that reconnects and retries on a dropped link.

Implementations§

Source§

impl BluestConnection

Source

pub async fn new(adapter: Adapter, device: Device) -> Result<Self>

Wrap an already-connected device, discovering its services and characteristics.

§Errors

Returns BleError::Backend on a bluest discovery failure.

Trait Implementations§

Source§

impl AdvertSource for BluestConnection

Source§

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

Stream Apple HAP advertisements by running a continuous adapter scan.

Spawns a background task that feeds every Apple (company id 0x004C) manufacturer-data frame into the returned channel. Forwarding is best-effort: frames are dropped when the receiver falls behind, not queued unboundedly, to ensure the task never blocks on backpressure and can always respond to a pause request. While a connect owns the radio (the ScanGate is paused) the task drops its scan stream and restarts it on resume. The task stops for good when the receiver is dropped or the adapter’s scan stream ends.

Intended for a single active watcher per connection: concurrent scan tasks would share one scanning flag and corrupt the pause-ack protocol.

§Errors

Returns crate::error::BleError on adapter/scan failures.

Source§

impl GattConnection for BluestConnection

Source§

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

Read one characteristic’s HAP instance id (its Instance-ID descriptor) without walking the whole tree — used to address the pairing characteristics before the (slow) full database sweep.
Source§

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

The maximum bytes that fit in a single GATT write — the HAP-BLE PDU fragment size. Backends that can’t determine the negotiated MTU return a conservative default.
Source§

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

A monotonically increasing link-generation counter that advances on every reconnect. A secure session minted at generation g is invalidated when the accessory drops the link (the count moves past g), so the holder must re-run Pair Verify before its next encrypted operation. Backends without a reconnect supervisor never invalidate sessions and return 0.
Source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, char_uuid: &'life1 str, value: &'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 a value to a characteristic identified by its UUID.
Source§

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

Read a characteristic’s current value by UUID.
Source§

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, char_uuid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Receiver<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to notifications on a characteristic; the receiver yields raw notification payloads.
Source§

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

Enumerate the accessory’s services and characteristics (with iids).
Source§

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

Release the active link. A sleepy HAP accessory only advertises and emits encrypted broadcasts while disconnected, so a caller watching for sleepy events must disconnect after setup. Default no-op for backends and mocks with no live link.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more