-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Simulations of Trait Bound Canister Dev | ||
|
||
This project contains various implementation for the same canister interface [Counter](counter.did). | ||
|
||
## Build and test | ||
|
||
``` | ||
dfx start --clean --background | ||
dfx deploy | ||
dfx canister call <CANISTER_NAME> read | ||
dfx canister call <CANISTER_NAME> inc | ||
dfx canister call <CANISTER_NAME> read | ||
... | ||
dfx stop | ||
``` | ||
|
||
## Canisters | ||
|
||
### unit_struct | ||
|
||
The baseline implementation which illustrates how the macro works. | ||
|
||
### build_script | ||
|
||
Instead of calling macro, we may want to use `build.rs` which generate the binding in `OUT_DIR`. | ||
|
||
If we want to allow bindgen configuration, `build.rs` is more convenient than macro. | ||
|
||
### stateful | ||
|
||
The struct has state and the trait required methods take `&self` or `&mut self` in argument. | ||
|
||
**Note**: Depends on `once_cell` crate to make sure that only one instance of the `Canister`. | ||
|
||
### async_trait | ||
|
||
The approach can work well with async. | ||
|
||
**Note**: Depends on `async-trait` crate. |