1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Read operations.

use super::EventKind;
use crate::vault::secret::SecretId;
use serde::{Deserialize, Serialize};

/// Read operations.
#[derive(Default, Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub enum ReadEvent {
    /// Default variant, should never be used.
    ///
    /// We need a variant so we can implement the Default
    /// trait which is required for decoding.
    #[default]
    Noop,

    /// Event used to indicate that a vault was read.
    ReadVault,

    /// Event used to indicate that a secret has been read.
    ReadSecret(SecretId),
}

impl ReadEvent {
    /// Get the event kind for this event.
    pub fn event_kind(&self) -> EventKind {
        match self {
            ReadEvent::Noop => EventKind::Noop,
            ReadEvent::ReadVault => EventKind::ReadVault,
            ReadEvent::ReadSecret(_) => EventKind::ReadSecret,
        }
    }
}