PtySystem

Trait PtySystem 

Source
pub trait PtySystem: Send + Sync {
    type Master: PtyMaster;
    type Child: PtyChild;

    // Required method
    fn spawn<S, I>(
        program: S,
        args: I,
        config: &PtyConfig,
    ) -> impl Future<Output = Result<(Self::Master, Self::Child)>> + Send
       where S: AsRef<OsStr> + Send,
             I: IntoIterator + Send,
             I::Item: AsRef<OsStr>;

    // Provided method
    fn spawn_shell(
        config: &PtyConfig,
    ) -> impl Future<Output = Result<(Self::Master, Self::Child)>> + Send { ... }
}
Expand description

Factory trait for creating PTY sessions.

This trait provides the main entry point for spawning processes in a PTY. Platform-specific implementations handle the details of PTY creation.

Required Associated Types§

Source

type Master: PtyMaster

The master PTY type for this platform.

Source

type Child: PtyChild

The child process type for this platform.

Required Methods§

Source

fn spawn<S, I>( program: S, args: I, config: &PtyConfig, ) -> impl Future<Output = Result<(Self::Master, Self::Child)>> + Send
where S: AsRef<OsStr> + Send, I: IntoIterator + Send, I::Item: AsRef<OsStr>,

Spawn a new process in a PTY.

§Arguments
  • program - The program to execute.
  • args - Command-line arguments (not including the program name).
  • config - PTY configuration.
§Returns

A tuple of the master PTY and child process handle.

Provided Methods§

Source

fn spawn_shell( config: &PtyConfig, ) -> impl Future<Output = Result<(Self::Master, Self::Child)>> + Send

Spawn a shell in a PTY using the default configuration.

On Unix, this uses the user’s shell from the SHELL environment variable or falls back to /bin/sh. On Windows, this uses cmd.exe.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§