pub struct LineWriter<W: ?Sized + Write> { /* private fields */ }Expand description
The BufWriter struct wraps a writer and buffers its output.
But it only does this batched write when it goes out of scope, or when the
internal buffer is full. Sometimes, you’d prefer to write each line as it’s
completed, rather than the entire buffer at once. Enter LineWriter. It
does exactly that.
Like BufWriter, a LineWriter’s buffer will also be flushed when the
LineWriter goes out of scope or when its internal buffer is full.
If there’s still a partial line in the buffer when the LineWriter is
dropped, it will flush those contents.
See std::io::LineWriter for more details.
Implementations§
Source§impl<W: Write> LineWriter<W>
impl<W: Write> LineWriter<W>
Sourcepub fn new(inner: W) -> LineWriter<W>
pub fn new(inner: W) -> LineWriter<W>
Creates a new LineWriter.
Sourcepub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>>
pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>>
Source§impl<W: ?Sized + Write> LineWriter<W>
impl<W: ?Sized + Write> LineWriter<W>
Trait Implementations§
Source§impl<W: ?Sized + Write> Write for LineWriter<W>
impl<W: ?Sized + Write> Write for LineWriter<W>
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.
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination.
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer.
Auto Trait Implementations§
impl<W> Freeze for LineWriter<W>
impl<W> RefUnwindSafe for LineWriter<W>where
W: RefUnwindSafe + ?Sized,
impl<W> Send for LineWriter<W>
impl<W> Sync for LineWriter<W>
impl<W> Unpin for LineWriter<W>
impl<W> UnsafeUnpin for LineWriter<W>where
W: UnsafeUnpin + ?Sized,
impl<W> UnwindSafe for LineWriter<W>where
W: UnwindSafe + ?Sized,
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