pub struct Enumerator { /* private fields */ }Expand description
Stateful device enumerator: holds the per-device probe cache so the polling
watcher reuses immutable data across ticks instead of re-handshaking every
device every ~2s. One-shot callers use the enumerate free function, which
runs against a fresh (empty) cache.
Implementations§
Source§impl Enumerator
impl Enumerator
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 tick.
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_BUDGET 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.