Skip to main content

ShellSession

Struct ShellSession 

Source
pub struct ShellSession {
    pub id: String,
    pub command: String,
    pub session_id: Option<String>,
    pub environment: CommandEnvironmentDiagnostics,
    /* private fields */
}

Fields§

§id: String§command: String§session_id: Option<String>

Bamboo session id that owns this background shell, if any. Set from the dispatch context (issue #84, phase 2a) so the registry can be queried per-session. None means the shell is untagged (e.g. spawned from tests).

§environment: CommandEnvironmentDiagnostics

Implementations§

Source§

impl ShellSession

Source

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

Source

pub async fn exit_code(&self) -> Option<i32>

Source

pub async fn read_output_since( &self, cursor: usize, filter: Option<&Regex>, ) -> (Vec<String>, usize, usize)

Source

pub async fn kill(&self) -> Result<(), String>

Request termination of the background shell. Flips running optimistically so Self::status reflects the kill immediately, then signals the completion task (the sole owner of the child handle) to start_kill and reap. The real exit code + the completion event/push are recorded by that task when the process is reaped. Never locks the child handle — see ShellSession::kill_notify.

Source

pub async fn write_stdin( &self, data: &str, append_newline: bool, ) -> Result<(), String>

Write data to the shell’s retained stdin pipe (issue #89). When append_newline is true a trailing \n is appended so the input is delivered as a complete line (e.g. to satisfy a line-oriented prompt).

Returns a clear error — never panics — when the shell was NOT spawned interactive (no stdin pipe to write to) or when the write/flush fails (the process has exited and the pipe is closed). Callers must not treat either case as fatal: a non-interactive shell simply has no stdin, and an exited shell’s pipe is gone.

Source

pub async fn close_stdin(&self) -> bool

Close the retained stdin pipe (issue #89), sending end-of-file to the child. Dropping the ChildStdin handle closes the pipe’s write end, so a consumer that reads stdin until EOF (e.g. cat, sort, a REPL) can terminate normally instead of running until killed.

Idempotent: a no-op on a non-interactive shell (stdin was already None) or one whose stdin was already closed. Returns true when a handle was actually taken (i.e. this was an interactive shell whose stdin was still open), false otherwise, so callers can distinguish.

Trait Implementations§

Source§

impl Debug for ShellSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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