nodedb_cluster/metadata_group/descriptors/
common.rs1use nodedb_types::Hlc;
6use serde::{Deserialize, Serialize};
7
8use crate::metadata_group::state::DescriptorState;
9
10#[derive(
15 Debug,
16 Clone,
17 PartialEq,
18 Eq,
19 Hash,
20 Serialize,
21 Deserialize,
22 zerompk::ToMessagePack,
23 zerompk::FromMessagePack,
24)]
25pub struct DescriptorId {
26 pub tenant_id: u64,
27 pub kind: DescriptorKind,
28 pub name: String,
29}
30
31impl DescriptorId {
32 pub fn new(tenant_id: u64, kind: DescriptorKind, name: impl Into<String>) -> Self {
33 Self {
34 tenant_id,
35 kind,
36 name: name.into(),
37 }
38 }
39}
40
41#[derive(
43 Debug,
44 Clone,
45 Copy,
46 PartialEq,
47 Eq,
48 Hash,
49 Serialize,
50 Deserialize,
51 zerompk::ToMessagePack,
52 zerompk::FromMessagePack,
53)]
54pub enum DescriptorKind {
55 Collection,
56 Index,
57 Trigger,
58 Sequence,
59 User,
60 Role,
61 Grant,
62 Rls,
63 ChangeStream,
64 MaterializedView,
65 Schedule,
66 Function,
67 Procedure,
68 Tenant,
69 ApiKey,
70 AuditRetention,
71}
72
73#[derive(
75 Debug,
76 Clone,
77 PartialEq,
78 Eq,
79 Serialize,
80 Deserialize,
81 zerompk::ToMessagePack,
82 zerompk::FromMessagePack,
83)]
84pub struct DescriptorHeader {
85 pub id: DescriptorId,
86 pub version: u64,
88 pub modification_time: Hlc,
90 pub state: DescriptorState,
92}
93
94impl DescriptorHeader {
95 pub fn new_public(id: DescriptorId, version: u64, modification_time: Hlc) -> Self {
96 Self {
97 id,
98 version,
99 modification_time,
100 state: DescriptorState::Public,
101 }
102 }
103}