Runtime

Trait Runtime 

Source
pub trait Runtime {
    // Required methods
    fn update_call<'life0, 'life1, 'async_trait, In, Out>(
        &'life0 self,
        id: Principal,
        method: &'life1 str,
        args: In,
        cycles: u128,
    ) -> Pin<Box<dyn Future<Output = Result<Out, IcError>> + Send + 'async_trait>>
       where In: ArgumentEncoder + Send + 'async_trait,
             Out: CandidType + DeserializeOwned + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query_call<'life0, 'life1, 'async_trait, In, Out>(
        &'life0 self,
        id: Principal,
        method: &'life1 str,
        args: In,
    ) -> Pin<Box<dyn Future<Output = Result<Out, IcError>> + Send + 'async_trait>>
       where In: ArgumentEncoder + Send + 'async_trait,
             Out: CandidType + DeserializeOwned + 'async_trait,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Abstract the canister runtime so that the client code can be reused:

  • in production using ic_cdk,
  • in unit tests by mocking this trait,
  • in integration tests by implementing this trait for PocketIc.

Required Methods§

Source

fn update_call<'life0, 'life1, 'async_trait, In, Out>( &'life0 self, id: Principal, method: &'life1 str, args: In, cycles: u128, ) -> Pin<Box<dyn Future<Output = Result<Out, IcError>> + Send + 'async_trait>>
where In: ArgumentEncoder + Send + 'async_trait, Out: CandidType + DeserializeOwned + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Defines how asynchronous inter-canister update calls are made.

Source

fn query_call<'life0, 'life1, 'async_trait, In, Out>( &'life0 self, id: Principal, method: &'life1 str, args: In, ) -> Pin<Box<dyn Future<Output = Result<Out, IcError>> + Send + 'async_trait>>
where In: ArgumentEncoder + Send + 'async_trait, Out: CandidType + DeserializeOwned + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Defines how asynchronous inter-canister query calls are made.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§