-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update test, diff is only space and newline
- Loading branch information
1 parent
c78744c
commit 0d1acfa
Showing
6 changed files
with
84 additions
and
196 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
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
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,22 @@ | ||
// 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}} | ||
pub struct {{service_name}}<'a>(pub Principal, pub &'a ic_agent::Agent); | ||
impl<'a> {{service_name}}<'a> { | ||
{{#each methods}} | ||
pub async fn {{id 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.{{this.mode}}(&self.0, "{{escape_debug this.name}}").with_arg(args).{{#if (eq this.mode "query")}}call{{else}}call_and_wait(){{/if}}.await?; | ||
Ok(Decode!(&bytes{{#each this.rets}}, {{this}}{{/each}})?) | ||
} | ||
{{/each}} | ||
} | ||
{{#if canister_id}} | ||
pub const CANISTER_ID : Principal = Principal::from_slice(&[{{principal_slice canister_id}}]); // {{canister_id}} | ||
{{/if}} | ||
{{/if}} |
Oops, something went wrong.