Skip to main content

ScriptedTerminal

Struct ScriptedTerminal 

Source
pub struct ScriptedTerminal { /* private fields */ }
Expand description

A scripted, in-memory terminal that replays canned input and captures output.

Implementations§

Source§

impl ScriptedTerminal

Source

pub fn key_driven() -> Self

A key-driven scripted terminal (advertises key input, like a raw TTY).

Source

pub fn line_driven() -> Self

A line-driven scripted terminal (advertises line input, like cooked stdio).

Source

pub fn with_line(self, line: impl Into<String>) -> Self

Queue one input line (line-driven scripts).

Source

pub fn with_lines<I, S>(self, lines: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Queue several input lines in order.

Source

pub fn with_key(self, key: Key) -> Self

Queue one keystroke (key-driven scripts).

Source

pub fn with_keys<I>(self, keys: I) -> Self
where I: IntoIterator<Item = Key>,

Queue several keystrokes in order.

Source

pub fn output(&self) -> &str

Everything written to the terminal so far, for assertions.

Source

pub const fn is_interactive(&self) -> bool

Whether the terminal is currently in interactive (raw) mode.

Trait Implementations§

Source§

impl Debug for ScriptedTerminal

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ScriptedTerminal

Source§

fn default() -> ScriptedTerminal

Returns the “default value” for a type. Read more
Source§

impl Terminal for ScriptedTerminal

Source§

fn capabilities(&self) -> Capabilities

The interaction model this terminal supports.
Source§

fn read_line(&mut self) -> AppResult<Option<String>>

Read one whole line (line-driven terminals). Read more
Source§

fn read_key(&mut self) -> AppResult<Key>

Read one decoded keystroke (key-driven terminals). Read more
Source§

fn write(&mut self, text: &str) -> AppResult<()>

Write text verbatim (no trailing newline). Read more
Source§

fn write_line(&mut self, text: &str) -> AppResult<()>

Write text followed by a newline (a carriage return + line feed in raw mode). Read more
Source§

fn flush(&mut self) -> AppResult<()>

Flush any buffered output. Read more
Source§

fn clear_last_lines(&mut self, _count: u16) -> AppResult<()>

Move the cursor up count lines and clear from there down, so the next frame overwrites the previous one. A no-op for line-driven terminals. Read more
Source§

fn begin_interactive(&mut self) -> AppResult<()>

Enter interactive (raw) mode before a key-driven loop. A no-op for line-driven terminals. Read more
Source§

fn end_interactive(&mut self) -> AppResult<()>

Leave interactive (raw) mode after a key-driven loop. A no-op for line-driven terminals. 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, 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, 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.