Skip to main content

Session

Struct Session 

Source
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>

Source

pub fn shell_name(&self) -> &'static str

The concrete shell running this session.

Source

pub fn control(&self) -> SessionControl

Returns a cloneable handle that can cancel this session or set its deadline.

Source

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.

Source

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.

Source

pub fn run_interactive(self) -> i32

Runs the session interactively: the virtual terminal rendered onto the host console. Returns the session exit status.

Source

pub fn run_interactive_controlled(self) -> SessionOutcome

Runs interactively and preserves cancellation/deadline as distinct outcomes.

Source

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.

Source

pub fn run_line_controlled<R: Read + Send + Sync>( self, input: &mut R, ) -> SessionOutcome

Runs line mode and preserves cancellation/deadline as distinct outcomes.

Auto Trait Implementations§

§

impl<'os> !RefUnwindSafe for Session<'os>

§

impl<'os> !Send for Session<'os>

§

impl<'os> !Sync for Session<'os>

§

impl<'os> !UnwindSafe for Session<'os>

§

impl<'os> Freeze for Session<'os>

§

impl<'os> Unpin for Session<'os>

§

impl<'os> UnsafeUnpin for Session<'os>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more