pub struct Session<'os> { /* private fields */ }Expand description
A running shell session against a booted OS.
Construct one with Session::unix or Session::windows, then run
it with Session::run_interactive (the virtual terminal) or
Session::run_line (scripted standard input).
Implementations§
Source§impl<'os> Session<'os>
impl<'os> Session<'os>
Sourcepub fn shell_name(&self) -> &'static str
pub fn shell_name(&self) -> &'static str
The concrete shell running this session.
Sourcepub fn control(&self) -> SessionControl
pub fn control(&self) -> SessionControl
Returns a cloneable handle that can cancel this session or set its deadline.
Sourcepub fn execute(&mut self, command: &str) -> Result<CommandOutput, SessionError>
pub fn execute(&mut self, command: &str) -> Result<CommandOutput, SessionError>
Executes one complete command and captures its output.
The shell object is retained, so working directory, variables,
aliases, history-independent shell state, background jobs, and every
machine mutation remain visible to later calls. Use
Session::execute_with_input when the command reads standard input.
Sourcepub fn execute_with_input(
&mut self,
command: &str,
input: impl AsRef<[u8]>,
) -> Result<CommandOutput, SessionError>
pub fn execute_with_input( &mut self, command: &str, input: impl AsRef<[u8]>, ) -> Result<CommandOutput, SessionError>
Executes one complete command with the supplied standard-input bytes.
Sourcepub fn run_interactive(self) -> i32
pub fn run_interactive(self) -> i32
Runs the session interactively: the virtual terminal rendered onto the host console. Returns the session exit status.
Sourcepub fn run_interactive_controlled(self) -> SessionOutcome
pub fn run_interactive_controlled(self) -> SessionOutcome
Runs interactively and preserves cancellation/deadline as distinct outcomes.
Sourcepub fn run_line<R: Read + Send + Sync>(self, input: &mut R) -> i32
pub fn run_line<R: Read + Send + Sync>(self, input: &mut R) -> i32
Runs the session in line mode: commands read from input, output
to the host’s stdout/stderr. Returns the session exit status.
Sourcepub fn run_line_controlled<R: Read + Send + Sync>(
self,
input: &mut R,
) -> SessionOutcome
pub fn run_line_controlled<R: Read + Send + Sync>( self, input: &mut R, ) -> SessionOutcome
Runs line mode and preserves cancellation/deadline as distinct outcomes.