Skip to main content

PocketIcStartupConfig

Struct PocketIcStartupConfig 

Source
pub struct PocketIcStartupConfig { /* private fields */ }
Expand description

Explicit bounded source and policy for one PocketIC startup.

Implementations§

Source§

impl PocketIcStartupConfig

Source

pub fn from_env(timeout: Duration) -> Result<Self, PocketIcStartupError>

Select the shared environment contract without discovery or downloads.

IC_TESTKIT_POCKET_IC_URL takes precedence over POCKET_IC_BIN. An explicitly empty or invalid selected value fails rather than falling back. URL mode never launches a version probe or claims server ownership. Binary mode resolves the explicit path and checks --version against pocket_ic::LATEST_SERVER_VERSION using the shared bounded capture engine. This is version qualification, not executable-byte admission; prepare and verify the binary with make install-tools / tools-check. The probe has its own timeout; subsequent startup has the same budget.

Source

pub fn spawn(server_binary: impl Into<PathBuf>, timeout: Duration) -> Self

Spawn and monitor one exact PocketIC server binary.

Startup allocates a unique private temporary directory while leaving the --port-file path absent for PocketIC to create.

Source

pub fn connect(server_url: impl Into<String>, timeout: Duration) -> Self

Connect to a caller-owned existing PocketIC server.

The URL is applied to the builder explicitly, so this mode never lets the upstream builder spawn a hidden server child.

Source

pub const fn with_server_hard_ttl(self, hard_ttl: Duration) -> Self

Set the hard lifetime passed to an ic-testkit-managed server.

Source

pub fn with_server_output_files( self, stdout: impl Into<PathBuf>, stderr: impl Into<PathBuf>, ) -> Self

Capture complete raw server streams in two caller-owned new files.

Requires spawn mode. Both parent directories must exist and remain under caller control; relative paths resolve at startup. Existing files, symlinks and special files are refused, without truncating them. New files have Unix mode 0600. Created output survives success, startup failure, cancellation and server teardown, including a partially prepared pair. The caller owns retention, disk budget and path presentation. Without this selection, output remains temporary and is removed during cleanup. Public output/error excerpts still read at most 16 KiB per stream.

Source

pub const fn timeout(&self) -> Duration

Complete startup deadline.

Source

pub const fn server_hard_ttl(&self) -> Option<Duration>

Explicit managed server hard lifetime, or None when disabled.

Source

pub fn server_binary(&self) -> Option<&Path>

Managed server binary, when this configuration spawns one.

Source

pub fn server_url(&self) -> Option<&str>

Existing caller-owned server URL, when configured.

Source

pub fn start_managed_server( self, ) -> Result<PocketIcManagedServer, PocketIcStartupError>

Start a caller-owned managed server without constructing an instance.

This requires a configuration created by Self::spawn. Readiness is bounded by Self::timeout. No hard TTL is passed by default; an explicit Self::with_server_hard_ttl value is passed to the child. Readiness requires a nonzero decimal port followed by a newline in a regular UTF-8 file of at most 64 bytes; oversized files fail with bounded diagnostics. Non-regular port files fail with PocketIcStartupError::Io and io::ErrorKind::InvalidData without waiting for a FIFO writer. The returned handle terminates the child on drop; use its URL with Self::connect to construct bounded instances.

Source

pub fn run_command( self, command: &mut Command, cancelled: impl FnMut() -> bool, ) -> Result<ExitStatus, PocketIcStartupError>

Run a command with IC_TESTKIT_POCKET_IC_URL set to this server.

Spawn mode retains the managed server until command completion; connect mode borrows the external server and never terminates it. The command’s IO and other environment selections remain caller-owned. Cancellation is polled after bounded startup and every 20 ms while the command runs. It returns an io::ErrorKind::Interrupted error after cleanup. If the owned server exits while the command is pending, the command is terminated and the server’s status and bounded diagnostics are returned as PocketIcStartupError::ServerExited. External servers are not monitored.

On Unix the command starts in a new owned process group. Completion, cancellation and observation failures terminate remaining group members before reaping the leader, using the same lifecycle engine as managed servers. This does not impose a command deadline or sandbox descendants that deliberately leave the owned group. Other hosts own the direct child.

Trait Implementations§

Source§

impl Clone for PocketIcStartupConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PocketIcStartupConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PocketIcStartupConfig

Source§

impl PartialEq for PocketIcStartupConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PocketIcStartupConfig

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<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