pub struct Enumerator { /* private fields */ }Expand description
Stateful device enumerator: owns persistent channels and the per-device
probe cache so the event-first watcher reuses immutable data across
reconciliations. One-shot callers use the enumerate free function, which
runs against a fresh (empty) cache.
Implementations§
Source§impl Enumerator
impl Enumerator
Sourcepub fn open_failures_last_tick(&self) -> bool
pub fn open_failures_last_tick(&self) -> bool
Whether the most recent enumerate pass failed to
open at least one HID++ node. false before the first pass.
On macOS a run of passes with this set is the observable signature of a denied Input Monitoring grant or a stale permission session — paired with the grant state it separates “grant it” from “log out”, which the bare open error cannot (the denial is silent).
Sourcepub fn retry_needed_last_tick(&self) -> bool
pub fn retry_needed_last_tick(&self) -> bool
Whether the last pass needs a bounded fast follow-up to advance a
probe/channel/cache recovery policy. false before the first pass.
Sourcepub fn with_backend(backend: Arc<dyn HidBackend>) -> Self
pub fn with_backend(backend: Arc<dyn HidBackend>) -> Self
An enumerator that walks backend — this host’s HID stack, a scripted
device tree in tests, or another host’s.
Sourcepub fn with_registry(self, registry: ChannelRegistry) -> Self
pub fn with_registry(self, registry: ChannelRegistry) -> Self
Publish this enumerator’s already-open channels into registry after
each settled inventory pass.
Sourcepub fn with_event_notifier(self, notifier: EventNotifier) -> Self
pub fn with_event_notifier(self, notifier: EventNotifier) -> Self
Subscribe this enumerator’s already-open channels to lifecycle events
and coalesce them into reconciliation requests sent through notifier.
Sourcepub fn with_probe_cache(self, store: Arc<dyn ProbeCacheStore>) -> Self
pub fn with_probe_cache(self, store: Arc<dyn ProbeCacheStore>) -> Self
Warm-start this enumerator’s immutable probe cache from store, and
write it back there whenever its persistable content changes.
A modifier rather than a constructor: persistence is orthogonal to the channel registry and the backend, so an enumerator can carry all three.
Sourcepub async fn enumerate(
&mut self,
) -> Result<Vec<DeviceInventory>, InventoryError>
pub async fn enumerate( &mut self, ) -> Result<Vec<DeviceInventory>, InventoryError>
One enumeration pass, reusing the cache from prior passes. Probes every
HID candidate concurrently (so one asleep node that burns the whole
PROBE_TIMEOUT can’t stall the others), reusing each device’s cached
immutable data when it’s present and fresh.
A node the OS still lists but whose probe fails (receiver registers unanswered, probe timeout, open failure) is not reported as absent: its last completed inventory is replayed for a bounded grace and its channel is reopened, so a transient HID++ glitch can’t masquerade as “no devices” (#218) — see the node ledger.