libobsbot_core/status.rs
1// SPDX-License-Identifier: GPL-3.0-only
2//! Hot-plug + periodic status events.
3
4use crate::types::Status;
5
6/// Event delivered to consumers of [`crate::Devices::events`].
7#[derive(Debug, Clone)]
8#[non_exhaustive]
9pub enum Event {
10 /// A new OBSBOT camera was plugged in.
11 DeviceAdded {
12 /// Serial of the device that connected.
13 serial: String,
14 },
15 /// An OBSBOT camera was unplugged.
16 DeviceRemoved {
17 /// Serial of the device that disconnected.
18 serial: String,
19 },
20 /// A periodic status sample from the status poller.
21 Status {
22 /// Serial of the device the status belongs to.
23 serial: String,
24 /// Status snapshot.
25 snapshot: Status,
26 },
27}
28
29/// Receiver end of the event channel returned by [`crate::Devices::events`].
30pub type EventReceiver = crossbeam_channel::Receiver<Event>;
31
32/// Sender end of the event channel; held internally by `Devices` and
33/// cloned into each opened `Device` so its status poller can push samples.
34pub(crate) type EventSender = crossbeam_channel::Sender<Event>;