sos_core/events/
device.rs

1//! Event for trusting and revoking devices.
2use super::{EventKind, LogEvent};
3use crate::device::{DevicePublicKey, TrustedDevice};
4
5/// Device event records trust and revocation of account devices.
6#[derive(Default, Debug, Clone, Eq, PartialEq)]
7pub enum DeviceEvent {
8    #[default]
9    #[doc(hidden)]
10    Noop,
11    /// Device was trusted.
12    Trust(TrustedDevice),
13    /// Device had it's trustworhtiness revoked.
14    ///
15    /// Typically this would occur when a device is lost
16    /// or stolen.
17    Revoke(DevicePublicKey),
18}
19
20impl LogEvent for DeviceEvent {
21    fn event_kind(&self) -> EventKind {
22        match self {
23            Self::Noop => EventKind::Noop,
24            Self::Trust(_) => EventKind::TrustDevice,
25            Self::Revoke(_) => EventKind::RevokeDevice,
26        }
27    }
28}