Skip to main content

reddb_file/
profile.rs

1//! File-level deployment profile vocabulary.
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum FileProfile {
5    Embedded,
6    Serverless,
7    PrimaryReplica,
8    Cluster,
9}
10
11impl FileProfile {
12    pub const fn as_str(self) -> &'static str {
13        match self {
14            Self::Embedded => "embedded",
15            Self::Serverless => "serverless",
16            Self::PrimaryReplica => "primary-replica",
17            Self::Cluster => "cluster",
18        }
19    }
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
23pub enum FileArtifactKind {
24    SingleRdb,
25    Manifest,
26    Wal,
27    Snapshot,
28    BootIndex,
29    Pack,
30    BaseBackup,
31    Timeline,
32}
33
34impl FileArtifactKind {
35    pub const fn as_str(self) -> &'static str {
36        match self {
37            Self::SingleRdb => "single-rdb",
38            Self::Manifest => "manifest",
39            Self::Wal => "wal",
40            Self::Snapshot => "snapshot",
41            Self::BootIndex => "boot-index",
42            Self::Pack => "pack",
43            Self::BaseBackup => "base-backup",
44            Self::Timeline => "timeline",
45        }
46    }
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn file_profiles_render_canonical_labels() {
55        let profiles = [
56            (FileProfile::Embedded, "embedded"),
57            (FileProfile::Serverless, "serverless"),
58            (FileProfile::PrimaryReplica, "primary-replica"),
59            (FileProfile::Cluster, "cluster"),
60        ];
61
62        for (profile, label) in profiles {
63            assert_eq!(profile.as_str(), label);
64        }
65    }
66
67    #[test]
68    fn artifact_kinds_render_canonical_labels() {
69        let kinds = [
70            (FileArtifactKind::SingleRdb, "single-rdb"),
71            (FileArtifactKind::Manifest, "manifest"),
72            (FileArtifactKind::Wal, "wal"),
73            (FileArtifactKind::Snapshot, "snapshot"),
74            (FileArtifactKind::BootIndex, "boot-index"),
75            (FileArtifactKind::Pack, "pack"),
76            (FileArtifactKind::BaseBackup, "base-backup"),
77            (FileArtifactKind::Timeline, "timeline"),
78        ];
79
80        for (kind, label) in kinds {
81            assert_eq!(kind.as_str(), label);
82        }
83    }
84}