Rustic is a framework for developing canisters on the Internet Computer.
Set environment variable RUSTIC_USER_PAGE_END
. This value should NOT change across upgrades!
Once you set the user page range, you can never change it! Make sure to leave enough space for future upgrades. Be reasonable and don't set the value too high either, as you pay storage fees for the entire page range even if empty.
The module must be initialized in the init hook of the main application. The rustic module must be initialized first before everything else.
```rust
pub fn init () { rustic::rustic_init();
// init code for your canister
} ```
The module has a post-upgrade method that you must call in your post-upgrade hook. ```rust
pub fn postupgrade () { rustic::rusticpost_upgrade();
// post upgrade code for your canister
} ```
When using the lifecycle
feature (enabled by default), in the post-upgrade hook of the new canister, the lifecycle_on_upgrade
method is called via calling rustic::rustic_post_upgrade
. For the semver you'll need to specify whether you want a major/minor/patchlevel version bump. If the stable memory layout changed (make sure you test compatibility as this is not checked by rustic), bump the stable memory version. If you bump the major version then the minor/patchlevel are ignored and will be set to start from 0.
Do NOT use the pre-upgrade hook in your application EVER. This feature shall be considered deprecated.
Update guard is not executed during unit tests (or any calls from within the canister).
#[update(guard = "only_owner")] pub fn transfer_ownership
expands to:
```rust
fn transferownership0() {
iccdk::setup();
let r: Result<(), String> = onlyowner();
if let Err(e) = r {
iccdk::api::call::reject(&e);
return;
}
iccdk::spawn(async {
let (newowner,) = iccdk::api::call::argdata();
let result = transferownership(newowner);
ic_cdk::api::call::reply(())
});
}
/// If the new_owner
is set to None
, then the ownership transfer is cancelled
pub fn transferownership(newowner: Option
MIT