Struct Buffer
pub struct Buffer(/* private field */);
Write colored text to memory.
Buffer is a platform independent abstraction for printing colored text to
an in memory buffer. When the buffer is printed using a BufferWriter, the
color information will be applied to the output device (a tty on Unix and a
console on Windows).
A Buffer is typically created by calling the BufferWriter.buffer
method, which will take color preferences and the environment into
account. However, buffers can also be manually created using no_color,
ansi or console (on Windows).
Implementations
impl Buffer
fn no_color() -> BufferCreate a buffer that drops all color information.
fn ansi() -> BufferCreate a buffer that uses ANSI escape sequences.
fn is_empty(&self) -> boolReturns true if and only if this buffer is empty.
fn len(&self) -> usizeReturns the length of this buffer in bytes.
fn clear(&mut self)Clears this buffer.
fn into_inner(self) -> Vec<u8>Consume this buffer and return the underlying raw data.
On Windows, this unrecoverably drops all color information associated with the buffer.
fn as_slice(&self) -> &[u8]Return the underlying data of the buffer.
fn as_mut_slice(&mut self) -> &mut [u8]Return the underlying data of the buffer as a mutable slice.
Trait Implementations
impl Clone for Buffer
fn clone(&self) -> Self
impl Debug for Buffer
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Write for Buffer
fn write(&mut self, buf: &[u8]) -> Result<usize>fn flush(&mut self) -> Result<()>
impl WriteColor for Buffer
fn supports_color(&self) -> boolfn supports_hyperlinks(&self) -> boolfn set_color(&mut self, spec: &ColorSpec) -> Result<()>fn set_hyperlink(&mut self, link: &HyperlinkSpec<'_>) -> Result<()>fn reset(&mut self) -> Result<()>fn is_synchronous(&self) -> bool