zaun_community_protocol/crypto/
context.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum ContextStatus {
6 V1,
8 Experimental,
10 Reserved,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
17pub enum Context {
18 Descriptor,
20 Delegation,
22 RootRotation,
24 MemberKey,
26 HostSession,
28 Checkpoint,
30 MemberReauth,
32 ExportManifest,
34 Verification,
36 VoiceKeyPackage,
38 VoiceSenderKeys,
40 BotPackage,
42}
43
44impl Context {
45 pub const ALL: [Self; 12] = [
47 Self::Descriptor,
48 Self::Delegation,
49 Self::RootRotation,
50 Self::MemberKey,
51 Self::HostSession,
52 Self::Checkpoint,
53 Self::MemberReauth,
54 Self::ExportManifest,
55 Self::Verification,
56 Self::VoiceKeyPackage,
57 Self::VoiceSenderKeys,
58 Self::BotPackage,
59 ];
60
61 #[must_use]
63 pub const fn as_bytes(self) -> &'static [u8] {
64 match self {
65 Self::Descriptor => b"zaun/v1/descriptor",
66 Self::Delegation => b"zaun/v1/delegation",
67 Self::RootRotation => b"zaun/v1/root-rotation",
68 Self::MemberKey => b"zaun/v1/member-key",
69 Self::HostSession => b"zaun/v1/host-session",
70 Self::Checkpoint => b"zaun/v1/checkpoint",
71 Self::MemberReauth => b"zaun/v1/member-reauth",
72 Self::ExportManifest => b"zaun/v1/export-manifest",
73 Self::Verification => b"zaun/v1/verification",
74 Self::VoiceKeyPackage => b"zaun/v1/voice-key-package",
75 Self::VoiceSenderKeys => b"zaun/v1/voice-sender-keys",
76 Self::BotPackage => b"zaun/v1/bot-package",
77 }
78 }
79
80 #[must_use]
82 pub const fn status(self) -> ContextStatus {
83 match self {
84 Self::Descriptor
85 | Self::Delegation
86 | Self::RootRotation
87 | Self::MemberKey
88 | Self::HostSession
89 | Self::MemberReauth
90 | Self::ExportManifest
91 | Self::BotPackage => ContextStatus::V1,
92 Self::Checkpoint | Self::VoiceKeyPackage | Self::VoiceSenderKeys => {
93 ContextStatus::Experimental
94 }
95 Self::Verification => ContextStatus::Reserved,
96 }
97 }
98}