Skip to main content

CanisterInstallExt

Trait CanisterInstallExt 

Source
pub trait CanisterInstallExt {
    // Required methods
    fn create_and_install(&self, spec: InstallSpec) -> Principal;
    fn try_create_and_install(
        &self,
        spec: InstallSpec,
    ) -> Result<Principal, CanisterInstallError>;
    fn create_and_install_many<I>(&self, specs: I) -> Vec<Principal>
       where I: IntoIterator<Item = InstallSpec>;
    fn try_create_and_install_many<I>(
        &self,
        specs: I,
    ) -> Result<Vec<Principal>, CanisterInstallError>
       where I: IntoIterator<Item = InstallSpec>;
    fn wait_out_install_code_rate_limit(&self, cooldown: Duration);
    fn retry_install_code<T, F>(
        &self,
        policy: RetryPolicy,
        op: F,
    ) -> Result<T, RejectResponse>
       where F: FnMut() -> Result<T, RejectResponse>;
}
Expand description

Generic canister installation and structured install-code retry policy.

The extension creates canisters using PocketIC defaults. InstallSpec::cycles is an additional top-up, not the complete initial balance.

Required Methods§

Source

fn create_and_install(&self, spec: InstallSpec) -> Principal

Create and install one canister from a reusable specification.

Source

fn try_create_and_install( &self, spec: InstallSpec, ) -> Result<Principal, CanisterInstallError>

Fallible counterpart to create_and_install.

Captures PocketIC panics during creation, cycle funding, and installation. The error identifies the stage and retains an id when creation succeeded.

Source

fn create_and_install_many<I>(&self, specs: I) -> Vec<Principal>
where I: IntoIterator<Item = InstallSpec>,

Sequentially create and install multiple canisters.

Source

fn try_create_and_install_many<I>( &self, specs: I, ) -> Result<Vec<Principal>, CanisterInstallError>
where I: IntoIterator<Item = InstallSpec>,

Fallible counterpart to create_and_install_many.

Source

fn wait_out_install_code_rate_limit(&self, cooldown: Duration)

Advance simulated time and rounds past an install-code cooldown.

Source

fn retry_install_code<T, F>( &self, policy: RetryPolicy, op: F, ) -> Result<T, RejectResponse>
where F: FnMut() -> Result<T, RejectResponse>,

Retry only while PocketIC reports install-code rate limiting.

RetryPolicy::max_attempts includes the initial call. Before each retry, this advances simulated time by the configured cooldown and executes two PocketIC ticks. Other rejections are returned unchanged.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§