pub trait CanisterInstallExt {
// Required methods
fn try_create_and_install(
&self,
spec: InstallSpec,
) -> Result<Principal, CanisterInstallError>;
fn wait_out_install_code_rate_limit(
&self,
cooldown: Duration,
) -> Result<(), ClientError>;
fn retry_install_code<T, F>(
&self,
policy: RetryPolicy,
op: F,
) -> Result<T, ClientError>
where F: FnMut() -> Result<T, ClientError>;
}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§
Sourcefn try_create_and_install(
&self,
spec: InstallSpec,
) -> Result<Principal, CanisterInstallError>
fn try_create_and_install( &self, spec: InstallSpec, ) -> Result<Principal, CanisterInstallError>
Create and install one canister from a reusable specification.
Retains typed client failures during creation, cycle funding, and installation. The error identifies the stage and retains an id when creation succeeded. Callers choose whether to collect diagnostics; this performs no diagnostic requests or error logging.
§Errors
Returns the failed creation or installation stage, retaining canister identity when available.
Sourcefn wait_out_install_code_rate_limit(
&self,
cooldown: Duration,
) -> Result<(), ClientError>
fn wait_out_install_code_rate_limit( &self, cooldown: Duration, ) -> Result<(), ClientError>
Advance simulated time once, then tick twice for an install-code cooldown. Zero duration skips time reads/writes while retaining both ticks.
§Errors
Returns the first client failure without dispatching remaining ticks.
Sourcefn retry_install_code<T, F>(
&self,
policy: RetryPolicy,
op: F,
) -> Result<T, ClientError>
fn retry_install_code<T, F>( &self, policy: RetryPolicy, op: F, ) -> Result<T, ClientError>
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.
§Errors
Returns non-rate-limit failures immediately, or the final rate-limit rejection. A cooldown failure stops further installation attempts.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl CanisterInstallExt for PocketIc
impl CanisterInstallExt for PocketIc
Source§fn try_create_and_install(
&self,
spec: InstallSpec,
) -> Result<Principal, CanisterInstallError>
fn try_create_and_install( &self, spec: InstallSpec, ) -> Result<Principal, CanisterInstallError>
Install one arbitrary wasm module from a generic install specification.
Source§fn wait_out_install_code_rate_limit(
&self,
cooldown: Duration,
) -> Result<(), ClientError>
fn wait_out_install_code_rate_limit( &self, cooldown: Duration, ) -> Result<(), ClientError>
Wait out the PocketIC install_code cooldown window inside the same instance.