Struct termcolor::Buffer [−][src]
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
[src]
pub fn no_color() -> Bufferⓘ
[src]
Create a buffer that drops all color information.
pub fn ansi() -> Bufferⓘ
[src]
Create a buffer that uses ANSI escape sequences.
pub fn is_empty(&self) -> bool
[src]
Returns true if and only if this buffer is empty.
pub fn len(&self) -> usize
[src]
Returns the length of this buffer in bytes.
pub fn clear(&mut self)
[src]
Clears this buffer.
pub fn into_inner(self) -> Vec<u8>
[src]
Consume this buffer and return the underlying raw data.
On Windows, this unrecoverably drops all color information associated with the buffer.
pub fn as_slice(&self) -> &[u8]
[src]
Return the underlying data of the buffer.
pub fn as_mut_slice(&mut self) -> &mut [u8]
[src]
Return the underlying data of the buffer as a mutable slice.
Trait Implementations
impl Write for Buffer
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
impl WriteColor for Buffer
[src]
Auto Trait Implementations
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,