Skip to main content

TestBackend

Struct TestBackend 

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

In-memory terminal backend for testing.

All output is captured in a buffer that can be inspected.

Implementations§

Source§

impl TestBackend

Source

pub fn new(width: u16, height: u16) -> Self

Create a new test backend with the given size.

Source

pub fn buffer(&self) -> &[u8]

Get the bytes written to this backend.

Source

pub fn clear_buffer(&mut self)

Clear the output buffer.

Source

pub fn is_raw_mode(&self) -> bool

Check if raw mode is active.

Source

pub fn is_mouse_enabled(&self) -> bool

Check if mouse capture is active.

Source

pub fn set_size(&mut self, width: u16, height: u16)

Set the terminal size (simulates a resize).

Trait Implementations§

Source§

impl Terminal for TestBackend

Source§

fn size(&self) -> Result<Size>

Get the current terminal size.
Source§

fn capabilities(&self) -> &TerminalCapabilities

Get the terminal’s capabilities.
Source§

fn enter_raw_mode(&mut self) -> Result<()>

Enter raw mode (disable line buffering, echo, etc.).
Source§

fn exit_raw_mode(&mut self) -> Result<()>

Exit raw mode (restore normal terminal state).
Source§

fn write_raw(&mut self, data: &[u8]) -> Result<()>

Write raw bytes to the terminal.
Source§

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

Flush buffered output to the terminal.
Source§

fn enable_mouse(&mut self) -> Result<()>

Enable mouse event capture.
Source§

fn disable_mouse(&mut self) -> Result<()>

Disable mouse event capture.

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.