Crates.io | junobuild-utils |
lib.rs | junobuild-utils |
version | 0.0.4 |
source | src |
created_at | 2024-02-04 17:39:51.470637 |
updated_at | 2024-10-18 14:21:55.244088 |
description | A collection of utilities for developers on Juno. |
homepage | https://juno.build |
repository | https://github.com/junobuild/juno |
max_upload_size | |
id | 1126524 |
size | 48,683 |
junobuild-utils
provides a collection of utilities designed to support developers working on Juno, facilitating easier data handling, serialization, deserialization, and working with specialized data types.
To include junobuild-utils
in your Rust project, add it as a dependency in your Cargo.toml
:
[dependencies]
junobuild-utils = "*"
Replace "*"
with the specific version you want to use, or omit the version to always use the latest version.
Decode the serialized document data received by a hook.
#[derive(Deserialize)]
struct MyData {
// Your data fields here
}
let decoded: MyData = decode_doc_data(&context.data.data.after.data).expect("Failed to decode data");
Encodes a Rust struct into serialized document data to prepare data to be stored.
#[derive(Serialize)]
struct MyData {
// Your data fields here
}
let encoded = encode_doc_data(&my_data).expect("Failed to encode data");
Work with custom data types such as DocDataPrincipal
for principals and DocDataBigInt
for bigint.
let principal = DocDataPrincipal { value: candid::Principal::anonymous() };
let big_int = DocDataBigInt { value: 123456789 };
Here are some useful links: