pub struct Command<'a> { /* private fields */ }Expand description
A builder for launching a command inside the guest.
This has a similar API to std::process::Command.
Implementations§
Source§impl<'a> Command<'a>
impl<'a> Command<'a>
Sourcepub fn args<I: IntoIterator>(&mut self, args: I) -> &mut Self
pub fn args<I: IntoIterator>(&mut self, args: I) -> &mut Self
Adds multiple arguments to the command.
Sourcepub fn current_dir(&mut self, dir: impl AsRef<str>) -> &mut Self
pub fn current_dir(&mut self, dir: impl AsRef<str>) -> &mut Self
Sets the current working directory for the command.
Sourcepub fn env_clear(&mut self) -> &mut Self
pub fn env_clear(&mut self) -> &mut Self
Clears the environment before setting the new environment.
Sourcepub fn env(
&mut self,
name: impl AsRef<str>,
value: impl AsRef<str>,
) -> &mut Self
pub fn env( &mut self, name: impl AsRef<str>, value: impl AsRef<str>, ) -> &mut Self
Sets an environment variable for the command.
Sourcepub fn env_remove(&mut self, name: impl AsRef<str>) -> &mut Self
pub fn env_remove(&mut self, name: impl AsRef<str>) -> &mut Self
Removes an environment variable for the command.
Sourcepub fn stdout(&mut self, stdout: impl Into<Stdio>) -> &mut Self
pub fn stdout(&mut self, stdout: impl Into<Stdio>) -> &mut Self
Sets the stdout for the command.
Sourcepub fn stderr(&mut self, stderr: impl Into<Stdio>) -> &mut Self
pub fn stderr(&mut self, stderr: impl Into<Stdio>) -> &mut Self
Sets the stderr for the command.
Sourcepub fn chroot(&mut self, root: impl AsRef<str>) -> &mut Self
pub fn chroot(&mut self, root: impl AsRef<str>) -> &mut Self
Sets the chroot directory for the command (Linux only).
Sourcepub fn pty(&mut self, allocate: bool) -> &mut Self
pub fn pty(&mut self, allocate: bool) -> &mut Self
Allocate a PTY for the child process (Linux guests only).
When set, stdin/stdout/stderr are all connected to a PTY secondary, enabling terminal features like Ctrl-C signal propagation and line editing. The PTY primary is relayed through the stdout pipe.
Sourcepub fn combine_stderr(&mut self, combine: bool) -> &mut Self
pub fn combine_stderr(&mut self, combine: bool) -> &mut Self
Redirect stderr to the stdout pipe.
When set, the child’s stderr is merged into stdout so callers receive interleaved output through a single stream.