Skip to main content

Formatter

Struct Formatter 

Source
pub struct Formatter<'t, 'alloc: 'cb, 'cb: 't> { /* private fields */ }
Expand description

Formatter that formats terminal content.

Implementations§

Source§

impl<'t, 'alloc: 'cb, 'cb: 't> Formatter<'t, 'alloc, 'cb>

Source

pub fn new( terminal: &'t Terminal<'alloc, 'cb>, opts: FormatterOptions, ) -> Result<Self>

Create a formatter for a terminal’s active screen.

Source

pub fn new_with_alloc<'ctx: 'alloc, Ctx>( alloc: &'alloc Allocator<'ctx, Ctx>, terminal: &'t Terminal<'alloc, 'cb>, opts: FormatterOptions, ) -> Result<Self>

Create a formatter for a terminal’s active screen.

See the crate-level documentation regarding custom memory management and lifetimes.

Source

pub fn format_alloc<'a, 'ctx: 'a, Ctx>( &mut self, alloc: Option<&'a Allocator<'ctx, Ctx>>, ) -> Result<Bytes<'a>>

Run the formatter and return an allocated buffer with the output.

Each call formats the current terminal state. The buffer is allocated using the provided allocator (or the default allocator if None).

Source

pub fn format_buf(&mut self, buf: &mut [u8]) -> Result<usize>

Run the formatter and produce output into the caller-provided buffer.

Each call formats the current terminal state. If the buffer is too small, returns Err(Error::OutOfSpace { required }) where required is the required size. The caller can then retry with a larger buffer.

Source

pub fn format_len(&mut self) -> Result<usize>

Query the required buffer size for the formatted output.

The result can be used to create a sufficiently large buffer for Formatter::format_buf.

Trait Implementations§

Source§

impl<'t, 'alloc: 'cb, 'cb: 't> Debug for Formatter<'t, 'alloc, 'cb>

Source§

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

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

impl Drop for Formatter<'_, '_, '_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'t, 'alloc, 'cb> Freeze for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> !RefUnwindSafe for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> !Send for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> !Sync for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> Unpin for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> UnsafeUnpin for Formatter<'t, 'alloc, 'cb>

§

impl<'t, 'alloc, 'cb> !UnwindSafe for Formatter<'t, 'alloc, 'cb>

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.