Trait term_transcript::traits::SpawnShell
source · pub trait SpawnShell: ConfigureCommand {
type ShellProcess: ShellProcess;
type Reader: Read + 'static + Send;
type Writer: Write + 'static + Send;
// Required method
fn spawn_shell(&mut self) -> Result<SpawnedShell<Self>>;
}
Expand description
Encapsulates spawning and sending inputs / receiving outputs from the shell.
The crate provides two principal implementations of this trait:
Command
andStdShell
communicate with the spawned process via OS pipes. Because stdin of the child process is not connected to a terminal / TTY, this can lead to the differences in output compared to launching the process in a terminal (no coloring, different formatting, etc.). On the other hand, this is the most widely supported option.PtyCommand
(available with theportable-pty
crate feature) communicates with the child process via a pseudo-terminal (PTY). This makes the output closer to what it would like in the terminal, at the cost of lesser platform coverage (Unix + newer Windows distributions).
External implementations are possible as well! E.g., for REPL applications written in Rust or packaged as a WASI module, it could be possible to write an implementation that “spawns” the application in the same process.
Required Associated Types§
sourcetype ShellProcess: ShellProcess
type ShellProcess: ShellProcess
Spawned shell process.
Required Methods§
sourcefn spawn_shell(&mut self) -> Result<SpawnedShell<Self>>
fn spawn_shell(&mut self) -> Result<SpawnedShell<Self>>
Spawns a shell process.
§Errors
Returns an error if the shell process cannot be spawned for whatever reason.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl SpawnShell for Command
impl SpawnShell for Command
Uses pipes to communicate with the spawned process. This has a potential downside that
the process output will differ from the case if the process was launched in the shell.
See PtyCommand
for an alternative that connects the spawned process to a pseudo-terminal
(PTY).