Skip to main content

ScanHub

Struct ScanHub 

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

The registry of everyone watching the scan.

Implementations§

Source§

impl ScanHub

Source

pub fn new() -> Self

A hub with no watchers and the radio off.

Source

pub fn add(&self, want: Want) -> (u64, Receiver<Candidate>, bool)

Register a watcher.

The bool is whether the radio scan has to be (re)started: either because this is the first watcher, or because it widened the filter.

Source

pub fn remove(&self, id: u64) -> bool

Remove a watcher, returning whether the radio scan should now stop.

Source

pub fn close_all(&self)

Drop every watcher, ending their streams.

For when the platform says the scan has failed: nothing further will arrive, so a chooser waiting on the stream should see it end rather than wait out its whole window for traffic that is not coming.

Not every platform has such a signal — CoreBluetooth has no scan-failed callback at all — so this is unused on some targets.

Source

pub fn is_watching_device(&self, id: &str) -> bool

Whether watchAdvertisements is running for this device — BluetoothDevice.watchingAdvertisements.

Source

pub fn is_watching(&self) -> bool

Whether anything still wants the radio scanning.

Source

pub fn contains(&self, id: u64) -> bool

Whether a given watcher is still registered — how a handed-out scan reports whether it is still live.

Source

pub fn scan_services(&self) -> Vec<BluetoothUuid>

The service UUIDs the radio scan should ask for.

Unused on a transport whose scan cannot be filtered at all — a raw HCI socket reports whatever the radio hears.

Empty means “everything”, and one watcher that needs everything makes it empty for all of them — a narrower scan would hide what that watcher asked for. The per-watcher filter still applies on the way out, so a wider radio scan costs traffic, never correctness.

Source

pub fn wants_duplicates(&self) -> bool

Whether the radio scan should report repeat sightings.

Also unused where the scan cannot be told either way.

Source

pub fn publish( &self, id: &str, name: Option<&str>, advertisement: &Advertisement, )

Offer one sighting to every watcher that wants it.

A watcher whose receiver has been dropped is left in place; remove is what deregisters, so that a caller who stops polling briefly does not silently lose its subscription.

Trait Implementations§

Source§

impl Default for ScanHub

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.