pub struct Session { /* private fields */ }Expand description
One running terminal application controlled in-process by its caller.
Session is the embedded equivalent of the CLI session lifecycle. It owns a PTY and the
visible terminal state, so callers can send input, wait for content, take shots, and resize
without spawning a new termctrl command for each action.
Implementations§
Source§impl Session
impl Session
Sourcepub fn start(
command: &[String],
cwd: Option<&Path>,
record: Option<&Path>,
options: &Options,
) -> Result<Self>
pub fn start( command: &[String], cwd: Option<&Path>, record: Option<&Path>, options: &Options, ) -> Result<Self>
Start command inside a live PTY-backed session.
Sourcepub fn send(&mut self, input: &[u8]) -> Result<()>
pub fn send(&mut self, input: &[u8]) -> Result<()>
Send one input burst to the terminal application.
Sourcepub fn send_all(&mut self, input: &[Vec<u8>], pace: Duration) -> Result<()>
pub fn send_all(&mut self, input: &[Vec<u8>], pace: Duration) -> Result<()>
Send ordered input bursts, optionally pacing them for recorded interactions.
Sourcepub fn wait_for_text(&mut self, text: &str, timeout: Duration) -> Result<()>
pub fn wait_for_text(&mut self, text: &str, timeout: Duration) -> Result<()>
Wait until visible terminal text contains text.
Sourcepub fn wait_for_idle(
&mut self,
settle: Duration,
timeout: Duration,
) -> Result<()>
pub fn wait_for_idle( &mut self, settle: Duration, timeout: Duration, ) -> Result<()>
Wait until no terminal output has arrived for settle.
Sourcepub fn wait_for_exit(
&mut self,
timeout: Duration,
) -> Result<Option<ProcessExit>>
pub fn wait_for_exit( &mut self, timeout: Duration, ) -> Result<Option<ProcessExit>>
Wait for the terminal application to exit, returning None on timeout.
Sourcepub fn capture(
&mut self,
settle: Duration,
deadline: Duration,
) -> Result<CaptureResult>
pub fn capture( &mut self, settle: Duration, deadline: Duration, ) -> Result<CaptureResult>
Capture visible terminal state and report whether it settled, exited, or reached a limit.
Sourcepub fn status(&mut self) -> Result<SessionStatus>
pub fn status(&mut self) -> Result<SessionStatus>
Inspect session lifecycle, geometry, and whether a visible frame is available.
Sourcepub fn logs(&mut self, ansi: bool) -> Result<Vec<u8>>
pub fn logs(&mut self, ansi: bool) -> Result<Vec<u8>>
Return readable normal-screen scrollback, or the exact retained ANSI/VT stream.
Sourcepub fn resize(
&mut self,
cols: u16,
rows: u16,
cell_width: u16,
cell_height: u16,
) -> Result<()>
pub fn resize( &mut self, cols: u16, rows: u16, cell_width: u16, cell_height: u16, ) -> Result<()>
Resize the PTY and reflow subsequent terminal parsing at the new dimensions.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Session
impl !Sync for Session
impl !UnwindSafe for Session
impl Freeze for Session
impl Send for Session
impl Unpin for Session
impl UnsafeUnpin for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.