Skip to main content

scan_stream

Function scan_stream 

Source
pub async fn scan_stream(
    timeout: Duration,
) -> Result<Receiver<DiscoveredBleAccessory>>
Expand description

Scan for HAP accessories incrementally, yielding each one as it is heard.

Like scan, but instead of blocking for the full timeout window it returns a channel receiver immediately; each accessory is sent as soon as its HAP advertisement is parsed, deduplicated by peripheral id within the window. The channel closes when the window elapses — or as soon as the receiver is dropped, which tears the scan down early: the background task drops its scan stream (stopping the radio scan) and then the adapter itself, so no central or (on Linux) D-Bus session outlives the call.

§Errors

Returns BleError::AccessoryNotFound if no BLE adapter is present and BleError::Backend on adapter/scan-start failures. Failures after the scan has started end the stream (the channel closes) rather than surfacing an error.