pub struct DevicePoller { /* private fields */ }Expand description
Polls the system audio device inventory at a fixed interval and reports connectivity changes as human-readable event strings.
Created once and polled repeatedly. The first DevicePoller::poll after
interval has elapsed performs the expensive CPAL enumeration; calls
before that return None immediately.
Consumers:
- TUI: call
poll()every tick (50 ms); the poller internally rate-limits. - Dashboard API: call
poll()in atokio::time::intervaltask.
Implementations§
Source§impl DevicePoller
impl DevicePoller
Sourcepub fn new(interval: Duration) -> Self
pub fn new(interval: Duration) -> Self
Create a poller with the given minimum interval between CPAL queries.
On creation, immediately takes a baseline snapshot so the first poll()
only reports changes that happen after construction.
Sourcepub fn poll(&mut self) -> Option<Vec<String>>
pub fn poll(&mut self) -> Option<Vec<String>>
Check for device changes. Returns Some(events) if devices were
added, removed, or changed since the last check (subject to interval
rate-limiting), or None if nothing changed or the interval hasn’t
elapsed yet.
Sourcepub fn snapshot(&self) -> &DevicesResponse
pub fn snapshot(&self) -> &DevicesResponse
The most recent device inventory snapshot (cached, does not query CPAL).