ic-query 0.52.4

Internet Computer query library for CloudEngine, NNS, SNS, ICRC, system canisters, and public network metadata
Documentation
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
use prost::Oneof;

///
/// RegistryError
///
/// Protobuf error returned by a registry canister lookup.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct RegistryError {
    #[prost(enumeration = "RegistryErrorCode", tag = "1")]
    pub code: i32,
    #[prost(string, tag = "2")]
    pub reason: String,
    #[prost(bytes = "vec", tag = "3")]
    pub key: Vec<u8>,
}

///
/// RegistryErrorCode
///
/// Protobuf error category returned by the registry canister.
///

#[derive(Clone, Copy, Debug, prost::Enumeration, Eq, PartialEq)]
#[repr(i32)]
pub enum RegistryErrorCode {
    MalformedMessage = 0,
    KeyNotPresent = 1,
    KeyAlreadyPresent = 2,
    VersionNotLatest = 3,
    VersionBeyondLatest = 4,
    Authorization = 5,
    InternalError = 999,
}

///
/// LargeValueChunkKeys
///
/// Protobuf chunk keys used to retrieve a large registry value.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct LargeValueChunkKeys {
    #[prost(bytes = "vec", repeated, tag = "1")]
    pub chunk_content_sha256s: Vec<Vec<u8>>,
}

///
/// RegistryGetValueRequest
///
/// Protobuf request for a registry key at an optional version.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct RegistryGetValueRequest {
    #[prost(message, optional, tag = "1")]
    pub version: Option<UInt64Value>,
    #[prost(bytes = "vec", tag = "2")]
    pub key: Vec<u8>,
}

///
/// UInt64Value
///
/// Protobuf wrapper for an unsigned 64-bit registry value.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct UInt64Value {
    #[prost(uint64, tag = "1")]
    pub value: u64,
}

///
/// RegistryGetValueResponse
///
/// This is the high-capacity `get_value` response wire shape. The upstream
/// proto calls it `HighCapacityRegistryGetValueResponse`; this crate keeps the
/// local name narrow because this adapter never exposes protobuf types.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct RegistryGetValueResponse {
    #[prost(message, optional, tag = "1")]
    pub error: Option<RegistryError>,
    #[prost(uint64, tag = "2")]
    pub version: u64,
    #[prost(oneof = "registry_get_value_response::Content", tags = "3, 4")]
    pub content: Option<registry_get_value_response::Content>,
    #[prost(uint64, tag = "5")]
    pub timestamp_nanoseconds: u64,
}

pub mod registry_get_value_response {
    use super::{LargeValueChunkKeys, Oneof};

    ///
    /// Content
    ///
    #[derive(Clone, Eq, Oneof, PartialEq)]
    pub enum Content {
        #[prost(bytes = "vec", tag = "3")]
        Value(Vec<u8>),
        #[prost(message, tag = "4")]
        LargeValueChunkKeys(LargeValueChunkKeys),
    }
}

///
/// RegistryGetLatestVersionResponse
///
/// Protobuf response containing the latest registry version.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct RegistryGetLatestVersionResponse {
    #[prost(uint64, tag = "1")]
    pub version: u64,
}

///
/// RegistryGetChangesSinceRequest
///
/// Protobuf request for one certified Registry delta batch after a version.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct RegistryGetChangesSinceRequest {
    /// Last Registry version already held by the caller.
    #[prost(uint64, tag = "1")]
    pub version: u64,
}

///
/// HighCapacityRegistryValue
///
/// One versioned value returned in an ordinary Registry delta.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct HighCapacityRegistryValue {
    /// Registry version at which this value was mutated.
    #[prost(uint64, tag = "2")]
    pub version: u64,
    /// Inline value, deletion marker, or large-value chunk references.
    #[prost(oneof = "high_capacity_registry_value::Content", tags = "1, 3, 4")]
    pub content: Option<high_capacity_registry_value::Content>,
    /// Registry-assigned mutation timestamp in nanoseconds.
    #[prost(uint64, tag = "5")]
    pub timestamp_nanoseconds: u64,
}

pub mod high_capacity_registry_value {
    use super::LargeValueChunkKeys;
    use prost::Oneof;

    ///
    /// Content
    ///
    /// Value representation in one high-capacity Registry delta.
    ///

    #[derive(Clone, Eq, Oneof, PartialEq)]
    pub enum Content {
        /// Complete inline value bytes.
        #[prost(bytes = "vec", tag = "1")]
        Value(Vec<u8>),
        /// True when this mutation deleted the key.
        #[prost(bool, tag = "3")]
        DeletionMarker(bool),
        /// Content-addressed chunks for one large value.
        #[prost(message, tag = "4")]
        LargeValueChunkKeys(LargeValueChunkKeys),
    }
}

///
/// HighCapacityRegistryDelta
///
/// All returned mutations for one Registry key.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct HighCapacityRegistryDelta {
    /// Raw Registry key bytes.
    #[prost(bytes = "vec", tag = "1")]
    pub key: Vec<u8>,
    /// Mutations for the key in Registry-version order.
    #[prost(message, repeated, tag = "2")]
    pub values: Vec<HighCapacityRegistryValue>,
}

///
/// HighCapacityRegistryGetChangesSinceResponse
///
/// Ordinary-query Registry deltas and the latest version observed by the query.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
pub struct HighCapacityRegistryGetChangesSinceResponse {
    /// Registry-side query error.
    #[prost(message, optional, tag = "1")]
    pub error: Option<RegistryError>,
    /// Latest Registry version observed by the query.
    #[prost(uint64, tag = "2")]
    pub version: u64,
    /// All key deltas since the requested version.
    #[prost(message, repeated, tag = "3")]
    pub deltas: Vec<HighCapacityRegistryDelta>,
}

///
/// HighCapacityRegistryAtomicMutateRequest
///
/// One atomic Registry delta committed under a certified version label.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
pub struct HighCapacityRegistryAtomicMutateRequest {
    /// Ordered mutations applied by the Registry version.
    #[prost(message, repeated, tag = "1")]
    pub mutations: Vec<HighCapacityRegistryMutation>,
    /// Preconditions checked before applying the atomic mutation.
    #[prost(message, repeated, tag = "5")]
    pub preconditions: Vec<RegistryPrecondition>,
    /// Registry-assigned mutation timestamp in nanoseconds since the Unix epoch.
    #[prost(uint64, tag = "6")]
    pub timestamp_nanoseconds: u64,
}

///
/// HighCapacityRegistryMutation
///
/// One mutation in a certified Registry atomic mutation request.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
pub struct HighCapacityRegistryMutation {
    /// Raw `RegistryMutation.Type` numeric discriminant.
    #[prost(int32, tag = "1")]
    pub mutation_type: i32,
    /// Raw Registry key bytes.
    #[prost(bytes = "vec", tag = "2")]
    pub key: Vec<u8>,
    /// Inline value bytes or large-value chunk references.
    ///
    /// Historical non-delete mutations with an empty legacy `bytes` value
    /// decode as `None`; the transport adapter interprets those as an empty
    /// inline value, matching the official Registry conversion.
    #[prost(oneof = "high_capacity_registry_mutation::Content", tags = "3, 4")]
    pub content: Option<high_capacity_registry_mutation::Content>,
}

#[cfg(feature = "certified-subnet-catalog-host")]
pub mod high_capacity_registry_mutation {
    use super::LargeValueChunkKeys;
    use prost::Oneof;

    ///
    /// Content
    ///
    /// Value representation in one high-capacity Registry mutation.
    ///

    #[derive(Clone, Eq, Oneof, PartialEq)]
    pub enum Content {
        /// Complete inline value bytes.
        #[prost(bytes = "vec", tag = "3")]
        Value(Vec<u8>),
        /// Content-addressed chunks that require bounded follow-up retrieval.
        #[prost(message, tag = "4")]
        LargeValueChunkKeys(LargeValueChunkKeys),
    }
}

///
/// RegistryMutationType
///
/// Official Registry mutation discriminants used by certified deltas.
///

#[derive(Clone, Copy, Debug, prost::Enumeration, Eq, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
#[repr(i32)]
pub enum RegistryMutationType {
    Insert = 0,
    Update = 1,
    Delete = 2,
    Upsert = 4,
}

///
/// RegistryPrecondition
///
/// Expected key version attached to one atomic Registry mutation.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
pub struct RegistryPrecondition {
    /// Registry key whose version is constrained.
    #[prost(bytes = "vec", tag = "1")]
    pub key: Vec<u8>,
    /// Required Registry version for the key.
    #[prost(uint64, tag = "2")]
    pub expected_version: u64,
}

///
/// RegistryCertifiedResponse
///
/// Protobuf response returned by the Registry's certified query methods.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
pub struct RegistryCertifiedResponse {
    /// Certified mixed hash-tree witness.
    #[prost(message, optional, tag = "1")]
    pub hash_tree: Option<RegistryMixedHashTree>,
    /// CBOR system certificate authenticating the tree root.
    #[prost(bytes = "vec", tag = "2")]
    pub certificate: Vec<u8>,
}

///
/// RegistryMixedHashTree
///
/// Protobuf representation of a certified Registry mixed hash tree.
///

#[derive(Clone, Eq, prost::Message, PartialEq)]
#[cfg(feature = "certified-subnet-catalog-host")]
pub struct RegistryMixedHashTree {
    /// Encoded tree node.
    #[prost(oneof = "registry_mixed_hash_tree::Tree", tags = "1, 2, 3, 4, 5")]
    pub tree: Option<registry_mixed_hash_tree::Tree>,
}

#[cfg(feature = "certified-subnet-catalog-host")]
pub mod registry_mixed_hash_tree {
    use super::RegistryMixedHashTree;
    use prost::Oneof;

    ///
    /// Fork
    ///
    /// Two child branches in a Registry mixed hash tree.
    ///

    #[derive(Clone, Eq, prost::Message, PartialEq)]
    pub struct Fork {
        /// Left child branch.
        #[prost(message, optional, boxed, tag = "1")]
        pub left_tree: Option<Box<RegistryMixedHashTree>>,
        /// Right child branch.
        #[prost(message, optional, boxed, tag = "2")]
        pub right_tree: Option<Box<RegistryMixedHashTree>>,
    }

    ///
    /// Labeled
    ///
    /// Label and child branch in a Registry mixed hash tree.
    ///

    #[derive(Clone, Eq, prost::Message, PartialEq)]
    pub struct Labeled {
        /// Raw branch label.
        #[prost(bytes = "vec", tag = "1")]
        pub label: Vec<u8>,
        /// Labeled child branch.
        #[prost(message, optional, boxed, tag = "2")]
        pub subtree: Option<Box<RegistryMixedHashTree>>,
    }

    ///
    /// Tree
    ///
    /// One node in a Registry mixed hash tree.
    ///

    #[derive(Clone, Eq, Oneof, PartialEq)]
    pub enum Tree {
        /// Empty tree node.
        #[prost(message, tag = "1")]
        Empty(()),
        /// Fork containing two child branches.
        #[prost(message, tag = "2")]
        Fork(Box<Fork>),
        /// Labeled child branch.
        #[prost(message, tag = "3")]
        Labeled(Box<Labeled>),
        /// Visible leaf bytes.
        #[prost(bytes, tag = "4")]
        LeafData(Vec<u8>),
        /// Pruned SHA-256 subtree digest.
        #[prost(bytes, tag = "5")]
        PrunedDigest(Vec<u8>),
    }
}