pub struct Buffer(pub(crate) BufferInner);
Expand description
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).
Tuple Fields§
§0: BufferInner
Implementations§
source§impl Buffer
impl Buffer
sourcepub(crate) fn new(choice: ColorChoice) -> Buffer ⓘ
pub(crate) fn new(choice: ColorChoice) -> Buffer ⓘ
Create a new buffer with the given color settings.
sourcepub fn into_inner(self) -> Vec<u8>
pub 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.
sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Return the underlying data of the buffer as a mutable slice.
Trait Implementations§
source§impl Write for Buffer
impl Write for Buffer
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)source§impl WriteColor for Buffer
impl WriteColor for Buffer
source§fn supports_color(&self) -> bool
fn supports_color(&self) -> bool
source§fn supports_hyperlinks(&self) -> bool
fn supports_hyperlinks(&self) -> bool
source§fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
fn set_color(&mut self, spec: &ColorSpec) -> Result<()>
source§fn set_hyperlink(&mut self, link: &HyperlinkSpec<'_>) -> Result<()>
fn set_hyperlink(&mut self, link: &HyperlinkSpec<'_>) -> Result<()>
source§fn reset(&mut self) -> Result<()>
fn reset(&mut self) -> Result<()>
source§fn is_synchronous(&self) -> bool
fn is_synchronous(&self) -> bool
false
. Read moreAuto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)