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
sourceimpl<W> Writer<W> where
W: Write,
impl<W> Writer<W> where
W: Write,
sourcepub fn new(inner: W) -> Writer<W>ⓘNotable traits for Writer<W>impl<W> Write for Writer<W> where
W: Write,
pub fn new(inner: W) -> Writer<W>ⓘNotable traits for Writer<W>impl<W> Write for Writer<W> where
W: Write,
W: Write,
Create a new Writer that writes to inner.
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
sourceimpl<W> Write for Writer<W> where
W: Write,
impl<W> Write for Writer<W> where
W: Write,
sourcefn 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
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Determines if this Writer has an efficient write_vectored
implementation. Read more
1.0.0 · sourcefn 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
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more