Struct strip_ansi_escapes::Writer
source · pub struct Writer<W>where
W: Write,{ /* private fields */ }
Expand description
Writer
wraps an underlying type that implements Write
, stripping ANSI escape sequences
from bytes written to it before passing them to the underlying writer.
Example
use std::io::{self, Write};
use strip_ansi_escapes::Writer;
let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar";
let mut writer = Writer::new(io::stdout());
// Only `foo bar` will be written to stdout
writer.write_all(bytes_with_colors)?;
Implementations§
source§impl<W> Writer<W>where
W: Write,
impl<W> Writer<W>where W: Write,
sourcepub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>>
pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>>
Unwraps this Writer
, returning the underlying writer.
The internal buffer is written out before returning the writer, which
may produce an IntoInnerError
.
Trait Implementations§
source§impl<W> Write for Writer<W>where
W: Write,
impl<W> Write for Writer<W>where W: Write,
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> !RefUnwindSafe for Writer<W>
impl<W> Send for Writer<W>where W: Send,
impl<W> Sync for Writer<W>where W: Sync,
impl<W> Unpin for Writer<W>where W: Unpin,
impl<W> !UnwindSafe for Writer<W>
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
Mutably borrows from an owned value. Read more