Skip to main content

Module monitor

Module monitor 

Source
Expand description

Shared monitoring primitives for device connectivity and config file changes.

Both the TUI main loop (sync, crossterm event loop) and the dashboard API (async, tokio) need to detect when audio devices appear/disappear and when the config file is edited on disk. This module provides the two polling / watching primitives they share, so neither consumer re-implements the logic.

Both types are synchronous and runtime-agnostic:

  • DevicePoller wraps a rate-limited CPAL enumeration loop and exposes a simple poll() -> Option<Vec<String>> interface.
  • ConfigFileWatcher spawns an OS-native file watcher thread (notify) and exposes poll() -> bool, matching the existing TUI contract.

Structsยง

ConfigFileWatcher
Watches the config file for changes using OS-native file notifications.
DevicePoller
Polls the system audio device inventory at a fixed interval and reports connectivity changes as human-readable event strings.