Skip to main content

Crate bity_ic_canister_state_macros

Crate bity_ic_canister_state_macros 

Source
Expand description

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_ic_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);
}

Macros§

canister_state
A macro that generates thread-safe state management functions for a canister.