1use candid::CandidType;
7use serde::Deserialize;
8
9#[cfg_attr(
16 doc,
17 doc = "EntityCatalogCounts\n\nCompact count metadata for one SHOW ENTITIES row."
18)]
19#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
20pub struct EntityCatalogCounts {
21 columns: u32,
22 indexes: u32,
23 relations: u32,
24 schema_version: u32,
25}
26
27impl EntityCatalogCounts {
28 #[must_use]
30 pub const fn new(columns: u32, indexes: u32, relations: u32, schema_version: u32) -> Self {
31 Self {
32 columns,
33 indexes,
34 relations,
35 schema_version,
36 }
37 }
38}
39
40#[cfg_attr(
41 doc,
42 doc = "EntityCatalogDescription\n\nRuntime catalog entry for one registered entity."
43)]
44#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
45pub struct EntityCatalogDescription {
46 entity_name: String,
47 entity_path: String,
48 store_path: String,
49 storage: String,
50 columns: u32,
51 indexes: u32,
52 relations: u32,
53 schema_version: u32,
54}
55
56impl EntityCatalogDescription {
57 #[must_use]
59 pub const fn new(
60 entity_name: String,
61 entity_path: String,
62 store_path: String,
63 storage: String,
64 counts: EntityCatalogCounts,
65 ) -> Self {
66 Self {
67 entity_name,
68 entity_path,
69 store_path,
70 storage,
71 columns: counts.columns,
72 indexes: counts.indexes,
73 relations: counts.relations,
74 schema_version: counts.schema_version,
75 }
76 }
77
78 #[must_use]
80 pub const fn entity_name(&self) -> &str {
81 self.entity_name.as_str()
82 }
83
84 #[must_use]
86 pub const fn entity_path(&self) -> &str {
87 self.entity_path.as_str()
88 }
89
90 #[must_use]
92 pub const fn store_path(&self) -> &str {
93 self.store_path.as_str()
94 }
95
96 #[must_use]
98 pub const fn storage(&self) -> &str {
99 self.storage.as_str()
100 }
101
102 #[must_use]
104 pub const fn columns(&self) -> u32 {
105 self.columns
106 }
107
108 #[must_use]
110 pub const fn indexes(&self) -> u32 {
111 self.indexes
112 }
113
114 #[must_use]
116 pub const fn relations(&self) -> u32 {
117 self.relations
118 }
119
120 #[must_use]
122 pub const fn schema_version(&self) -> u32 {
123 self.schema_version
124 }
125}
126
127#[cfg_attr(
134 doc,
135 doc = "StoreCatalogDescription\n\nRuntime catalog entry for one registered store."
136)]
137#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
138pub struct StoreCatalogDescription {
139 store_path: String,
140 storage: String,
141}
142
143impl StoreCatalogDescription {
144 #[must_use]
146 pub const fn new(store_path: String, storage: String) -> Self {
147 Self {
148 store_path,
149 storage,
150 }
151 }
152
153 #[must_use]
155 pub const fn store_path(&self) -> &str {
156 self.store_path.as_str()
157 }
158
159 #[must_use]
161 pub const fn storage(&self) -> &str {
162 self.storage.as_str()
163 }
164}
165
166#[cfg_attr(
173 doc,
174 doc = "MemoryCatalogDescription\n\nRuntime catalog entry for one stable-memory allocation."
175)]
176#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
177pub struct MemoryCatalogDescription {
178 tag: String,
179 memory_id: u8,
180 store_path: String,
181}
182
183impl MemoryCatalogDescription {
184 #[must_use]
186 pub const fn new(tag: String, memory_id: u8, store_path: String) -> Self {
187 Self {
188 tag,
189 memory_id,
190 store_path,
191 }
192 }
193
194 #[must_use]
196 pub const fn tag(&self) -> &str {
197 self.tag.as_str()
198 }
199
200 #[must_use]
202 pub const fn memory_id(&self) -> u8 {
203 self.memory_id
204 }
205
206 #[must_use]
208 pub const fn store_path(&self) -> &str {
209 self.store_path.as_str()
210 }
211}