DeviceMonitor
pub struct DeviceMonitor
A running device monitor: the superset of HotplugMonitor.
The same arrivals and removals, plus claim transitions with
DeviceMonitorOptions::watching_claims, plus cameras on the
network with DeviceMonitorOptions::watching_network.
Stops when dropped, which waits for any callback in flight and for the claim poll to finish.
There is one monitor process-wide, so this and
HotplugMonitor replace each other rather than running side by
side, and either stop function ends whichever is running. Both
guards therefore share one flag: two of either kind, in any
combination, would let the first one's Drop stop the second
one's monitor and release a closure the SDK still had the pointer
to.
The first claim poll establishes what is claimed rather than reporting it, so a camera that was already busy when watching started does not arrive as a fresh claim. A device list would otherwise flash "in use" for cameras whose state never changed.
Examples
# fn main() -> optris_sdk::Result<()> {
let options = optris_sdk::DeviceMonitorOptions::new()
.watching_claims(true);
let _monitor = optris_sdk::DeviceMonitor::start(options, |device, change| {
println!("{} {change:?}", device.serial);
})?;
std::thread::sleep(std::time::Duration::from_secs(30));
# Ok(())
# }