pub struct Prefixer<'w> {
pub first_line_prefix: String,
pub next_line_prefix: String,
pub writer: &'w mut dyn Write,
pub is_first_line: bool,
pub needs_prefix: bool,
}Expand description
A Write adapter that prefixes each written line.
This type uses a dyn Write instead of impl Write to avoid a trait-recursion explosion in
crate::writeln_error_to_writer.
Fields§
§first_line_prefix: StringPrefix for the very first line.
next_line_prefix: StringPrefix for subsequent lines.
writer: &'w mut dyn WriteThe underlying writer.
is_first_line: boolWhether the next write is still on the first line.
needs_prefix: boolWhether the next write should include a prefix.
Implementations§
Trait Implementations§
Source§impl<'w> Write for Prefixer<'w>
impl<'w> Write for Prefixer<'w>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes 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> Freeze for Prefixer<'w>
impl<'w> !RefUnwindSafe for Prefixer<'w>
impl<'w> !Send for Prefixer<'w>
impl<'w> !Sync for Prefixer<'w>
impl<'w> Unpin for Prefixer<'w>
impl<'w> !UnwindSafe for Prefixer<'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