Skip to content

Latest commit

 

History

History

ic-cdk-bindgen

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

ic-cdk-bindgen

Generate Rust bindings from Candid to make inter-canister calls.

How to use

  1. Canister project add ic-cdk-bindgen as a build dependency.
[build-dependencies]
ic-cdk-bindgen = "0.1"
  1. Add build.rs to generate Rust bindings in the source directory with config options.
use ic_cdk_bindgen::{Builder, Config};
fn main() {
    let counter = Config::new("counter");
    let mut builder = Builder::new();
    builder.add(counter);
    builder.build(None);  // default write to src/declarations
}
  1. In Canister code,
mod declarations;
use declarations::counter::counter;

counter.inc().await?