Skip to main content

ProcessSpawner

Trait ProcessSpawner 

pub trait ProcessSpawner: Send + Sync {
    type Context: LaunchContext;
    type Handle: Send + 'static;
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn spawn(
        &self,
        program: &OsStr,
        args: &[OsString],
        context: &Self::Context,
    ) -> Result<Self::Handle, Self::Error>;
}
Expand description

Spawns child processes (daemon, client consoles, plugin hosts) on the host platform.

Required Associated Types§

type Context: LaunchContext

Per-spawn context type; see LaunchContext.

type Handle: Send + 'static

Opaque handle to a successfully spawned child.

Only Send + 'static is required; the bound omits Sync so platform implementations can return handles intended for single-owner mutation (e.g. tokio::process::Child) without wrapping them in an interior-mutability container.

type Error: Error + Send + Sync + 'static

Error type returned when spawning fails.

Required Methods§

fn spawn( &self, program: &OsStr, args: &[OsString], context: &Self::Context, ) -> Result<Self::Handle, Self::Error>

Spawn program with args under the supplied context.

§Arguments
  • program - Executable to launch (absolute path or a PATH-resolvable name).
  • args - Command-line arguments passed to the child.
  • context - Platform-specific launch context.
§Returns

Platform-specific handle to the spawned process, or a platform error if the spawn failed.

Implementors§