Skip to main content

CachedStandaloneCanisterFixturePool

Struct CachedStandaloneCanisterFixturePool 

Source
pub struct CachedStandaloneCanisterFixturePool<const CAPACITY: usize> { /* private fields */ }
Expand description

Caller-owned bounded pool of independently restorable standalone fixtures.

Each slot owns one PocketIC instance, one installed canister, and one captured baseline snapshot. Acquiring a populated slot restores that snapshot before returning it. At most CAPACITY leases can overlap; a caller waits only when every slot is in use.

One pool represents one logical fixture recipe. Every call to acquire must supply a builder for the same Wasm, init arguments, topology, and seeded baseline. The builder is not evaluated on a cache hit, so callers should use a separate pool for each recipe.

Snapshot restoration rewinds the installed canister, not the surrounding PocketIC instance. Instance time, other canisters, and cycle changes not covered by the selected SnapshotRestoreFunding policy may persist.

The pool contains no process-global state. Downstream suites select a capacity that fits their host and keep lifecycle-sensitive tests on fresh StandaloneCanisterFixture values when snapshot restoration is not the intended isolation boundary.

Implementations§

Source§

impl<const CAPACITY: usize> CachedStandaloneCanisterFixturePool<CAPACITY>

Source

pub const fn new() -> Self

Create an empty caller-owned fixture pool.

§Panics

Panics at compile time for a statically initialized zero-capacity pool, or at runtime if constructed dynamically with zero capacity.

Source

pub const fn with_restore_funding(self, funding: SnapshotRestoreFunding) -> Self

Select the cycle-funding policy applied immediately before each snapshot restore.

Source

pub fn acquire<B>( &self, build: B, ) -> Result<(CachedStandaloneCanisterFixtureGuard<'_>, bool), ControllerSnapshotError>

Acquire one isolated fixture, building a slot on first use and restoring its captured snapshot on later uses.

build must create the same logical fixture baseline on every call to this pool. It runs only when an empty slot is first populated or a dead PocketIC instance must be replaced.

A recognized dead-instance transport failure evicts and rebuilds only the affected slot. Other snapshot failures are returned unchanged and invalidate the possibly partially restored slot for the next lease.

§Errors

Returns the structured snapshot capture or restore failure for the selected slot.

Source

pub fn acquire_with_outcome<B>( &self, build: B, ) -> Result<(CachedStandaloneCanisterFixtureGuard<'_>, StandaloneFixturePoolOutcome), StandaloneFixturePoolError>

Acquire one fixture with structured lifecycle outcome and phase timings.

This is the diagnostic counterpart to acquire. It distinguishes a new slot from restoration and reconstruction while the compatibility method continues to report restoration as a boolean.

§Errors

Returns the failed preparation stage, the structured snapshot error, and all phase timings completed before failure. If dead-transport restoration and replacement capture both fail, both errors are retained.

Trait Implementations§

Source§

impl<const CAPACITY: usize> Default for CachedStandaloneCanisterFixturePool<CAPACITY>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const CAPACITY: usize> !Freeze for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> RefUnwindSafe for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> Send for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> Sync for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> Unpin for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> UnsafeUnpin for CachedStandaloneCanisterFixturePool<CAPACITY>

§

impl<const CAPACITY: usize> UnwindSafe for CachedStandaloneCanisterFixturePool<CAPACITY>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more