candid_parser 0.3.1

Candid is an interface description language (IDL) for interacting with canisters running on the Internet Computer. This crate contains the parser and the binding generator for Candid.
Documentation
// This is an experimental feature to generate Rust binding from Candid.
// You may want to manually adjust some of the types.
#![allow(dead_code, unused_imports)]
use {{candid_crate}}::{self, CandidType, Deserialize, Principal};
use ic_cdk::api::call::CallResult as Result;

{{type_defs}}
{{#if methods}}
{{#each actor_docs}}
{{../doc_comment_prefix}}{{this}}
{{/each}}
pub struct {{PascalCase service_name}}(pub Principal);
impl {{PascalCase service_name}} {
  {{#each methods}}
  {{#each this.docs}}
  {{../../doc_comment_prefix}}{{this}}
  {{/each}}
  pub async fn {{this.name}}(&self{{#each this.args}}, {{this.0}}: &{{this.1}}{{/each}}) -> Result<({{#each this.rets}}{{this}},{{/each}})> {
    ic_cdk::call(self.0, "{{escape_debug this.original_name}}", ({{#each this.args}}{{this.0}},{{/each}})).await
  }
  {{/each}}
}
{{#if canister_id}}
{{doc_comment_prefix}}Canister ID: `{{canister_id}}`
pub const CANISTER_ID : Principal = Principal::from_slice(&[{{principal_slice canister_id}}]);
pub const {{snake_case service_name}} : {{PascalCase service_name}} = {{PascalCase service_name}}(CANISTER_ID);
{{/if}}
{{/if}}
{{#if tests}}
{{tests}}
{{/if}}