Skip to main content

ProcessSpawner

Trait ProcessSpawner 

Source
pub trait ProcessSpawner {
    type Process: Process;

    // Required method
    fn spawn(
        &self,
        plan: &SpawnPlan,
    ) -> impl Future<Output = Result<Spawned<Self::Process>, ProcessError>> + Send;
}
Expand description

Trait for spawning child processes.

The production backend StdProcessSpawner wraps tokio::process::Command; a scriptable test-double mock lives alongside under [crate::mock_impl] but is gated to test builds only.

Consumers borrow a ProcessSpawner implementation generically rather than depending on either concrete impl, which keeps test code free of the production tokio command wiring while remaining on the same tokio runtime.

Required Associated Types§

Source

type Process: Process

The implementation’s concrete Process type.

Required Methods§

Source

fn spawn( &self, plan: &SpawnPlan, ) -> impl Future<Output = Result<Spawned<Self::Process>, ProcessError>> + Send

Spawn a child process per plan.

On success, both stdout and stderr are configured as pipes and returned in the Spawned value’s fields; stdin is closed. The returned future is Send so the executor can spawn it onto a multi-threaded runtime.

§Errors

Returns ProcessError::NonAbsoluteCwd when plan.cwd is relative, and ProcessError::SpawnFailed when the OS refuses to launch the child.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§