Struct futures_util::io::LineWriter
source · pub struct LineWriter<W: AsyncWrite> { /* private fields */ }
Expand description
Wrap a writer, like BufWriter
does, but prioritizes buffering lines
This was written based on std::io::LineWriter
which goes into further details
explaining the code.
Buffering is actually done using BufWriter
. This class will leverage BufWriter
to write on-each-line.
Implementations§
source§impl<W: AsyncWrite> LineWriter<W>
impl<W: AsyncWrite> LineWriter<W>
sourcepub fn new(inner: W) -> Self
pub fn new(inner: W) -> Self
Create a new LineWriter
with default buffer capacity. The default is currently 1KB
which was taken from std::io::LineWriter
sourcepub fn with_capacity(capacity: usize, inner: W) -> Self
pub fn with_capacity(capacity: usize, inner: W) -> Self
Creates a new LineWriter
with the specified buffer capacity.
Trait Implementations§
source§impl<W: AsyncWrite> AsyncWrite for LineWriter<W>
impl<W: AsyncWrite> AsyncWrite for LineWriter<W>
source§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Forward to buf_writer
’s BufWriter::poll_flush()
source§fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Forward to buf_writer
’s BufWriter::poll_close()
source§impl<W: Debug + AsyncWrite> Debug for LineWriter<W>
impl<W: Debug + AsyncWrite> Debug for LineWriter<W>
impl<'__pin, W: AsyncWrite> Unpin for LineWriter<W>where
__Origin<'__pin, W>: Unpin,
Auto Trait Implementations§
impl<W> Freeze for LineWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for LineWriter<W>where
W: RefUnwindSafe,
impl<W> Send for LineWriter<W>where
W: Send,
impl<W> Sync for LineWriter<W>where
W: Sync,
impl<W> UnwindSafe for LineWriter<W>where
W: UnwindSafe,
Blanket Implementations§
source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
source§fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self> ⓘwhere
Self: Unpin,
Creates a future which will entirely flush this
AsyncWrite
. Read moresource§fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
fn close(&mut self) -> Close<'_, Self> ⓘwhere
Self: Unpin,
Creates a future which will entirely close this
AsyncWrite
.source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
Creates a future which will write bytes from
buf
into the object. Read moresource§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self> ⓘwhere
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self> ⓘwhere
Self: Unpin,
Creates a future which will write bytes from
bufs
into the object using vectored
IO operations. Read moresource§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