#dfinity #subcanister #state #canister

bity-ic-canister-state-macros

Description spécifique de la crate

3 unstable releases

0.2.1 Apr 1, 2025
0.2.0 Apr 1, 2025
0.1.0 Mar 14, 2025

#2 in #subcanister

Download history 109/week @ 2025-03-11 15/week @ 2025-03-18 2/week @ 2025-03-25 228/week @ 2025-04-01 8/week @ 2025-04-08 5/week @ 2025-04-15

241 downloads per month

MIT license

10KB
74 lines

Module for managing canister state in Internet Computer canisters.

This module provides a macro for creating thread-safe state management in canisters, with functions for initialization, reading, and modifying the state.

Example

use bity_dfinity_library::canister_state_macros::canister_state;

struct MyState {
    counter: u64,
}

canister_state!(MyState);

fn init() {
    init_state(MyState { counter: 0 });
}

fn increment() {
    mutate_state(|state| state.counter += 1);
}

No runtime deps