// 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, Encode, Decode};
type Result<T> = std::result::Result<T, ic_agent::AgentError>;
{{type_defs}}
{{#if methods}}
{{#each actor_docs}}
{{../doc_comment_prefix}}{{this}}
{{/each}}
pub struct {{PascalCase service_name}}<'a>(pub Principal, pub &'a ic_agent::Agent);
impl<'a> {{PascalCase service_name}}<'a> {
{{#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<{{vec_to_arity this.rets}}> {
let args = Encode!({{#each this.args}}&{{this.0}}{{#unless @last}},{{/unless}}{{/each}})?;
let bytes = self.1.{{#if (eq this.mode "update")}}update{{else}}query{{/if}}(&self.0, "{{escape_debug this.original_name}}").with_arg(args).{{#if (eq this.mode "update")}}call_and_wait{{else}}call{{/if}}().await?;
Ok(Decode!(&bytes{{#each this.rets}}, {{this}}{{/each}})?)
}
{{/each}}
}
{{#if canister_id}}
{{doc_comment_prefix}}Canister ID: `{{canister_id}}`
pub const CANISTER_ID : Principal = Principal::from_slice(&[{{principal_slice canister_id}}]);
{{/if}}
{{/if}}
{{#if tests}}
{{tests}}
{{/if}}