pub struct ScanHub { /* private fields */ }Expand description
The registry of everyone watching the scan.
Implementations§
Source§impl ScanHub
impl ScanHub
Sourcepub fn add(&self, want: Want) -> (u64, Receiver<Candidate>, bool)
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.
Sourcepub fn remove(&self, id: u64) -> bool
pub fn remove(&self, id: u64) -> bool
Remove a watcher, returning whether the radio scan should now stop.
Sourcepub fn close_all(&self)
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.
Sourcepub fn is_watching_device(&self, id: &str) -> bool
pub fn is_watching_device(&self, id: &str) -> bool
Whether watchAdvertisements is running for this device —
BluetoothDevice.watchingAdvertisements.
Sourcepub fn is_watching(&self) -> bool
pub fn is_watching(&self) -> bool
Whether anything still wants the radio scanning.
Sourcepub fn contains(&self, id: u64) -> bool
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.
Sourcepub fn scan_services(&self) -> Vec<BluetoothUuid>
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.
Sourcepub fn wants_duplicates(&self) -> bool
pub fn wants_duplicates(&self) -> bool
Whether the radio scan should report repeat sightings.
Also unused where the scan cannot be told either way.
Sourcepub fn publish(
&self,
id: &str,
name: Option<&str>,
advertisement: &Advertisement,
)
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.