junobuild_utils/serializers/types.rs
1use candid::Principal as CandidPrincipal;
2
3/// Represents a wrapper around the `candid::Principal` type.
4///
5/// This struct is designed to encapsulate a Candid Principal, allowing for
6/// integration and usage within Juno hooks contexts.
7///
8/// # Fields
9/// - `value`: The `Principal` this struct wraps.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub struct DocDataPrincipal {
12 pub value: CandidPrincipal,
13}
14
15/// Represents a large integer value for document data, particularly useful for interacting with
16/// languages or environments that support large numeric types, such as the `bigint` in JavaScript.
17///
18/// # Fields
19/// - `value`: A `u64` integer representing the large numeric value encapsulated by this struct.
20#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
21pub struct DocDataBigInt {
22 pub value: u64,
23}
24
25/// Represents a byte array value for document data, mirroring JavaScript's `Uint8Array`.
26///
27/// This struct is useful for transporting raw binary data across the JSON boundary,
28/// where it is serialized as `{ "__uint8array__": number[] }` (see custom serde impl).
29///
30/// # Fields
31/// - `value`: The underlying bytes.
32#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
33pub struct DocDataUint8Array {
34 pub value: Vec<u8>,
35}