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>
impl<'t, 'alloc: 'cb, 'cb: 't> Formatter<'t, 'alloc, 'cb>
Sourcepub fn new(
terminal: &'t Terminal<'alloc, 'cb>,
opts: FormatterOptions,
) -> Result<Self>
pub fn new( terminal: &'t Terminal<'alloc, 'cb>, opts: FormatterOptions, ) -> Result<Self>
Create a formatter for a terminal’s active screen.
Sourcepub fn new_with_alloc<'ctx: 'alloc, Ctx>(
alloc: &'alloc Allocator<'ctx, Ctx>,
terminal: &'t Terminal<'alloc, 'cb>,
opts: FormatterOptions,
) -> Result<Self>
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.
Sourcepub fn format_alloc<'a, 'ctx: 'a, Ctx>(
&mut self,
alloc: Option<&'a Allocator<'ctx, Ctx>>,
) -> Result<Bytes<'a>>
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).
Sourcepub fn format_buf(&mut self, buf: &mut [u8]) -> Result<usize>
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.
Sourcepub fn format_len(&mut self) -> Result<usize>
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.