Struct LineWriter

pub struct LineWriter<W: AsyncWrite> { /* private fields */ }

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

impl<W: AsyncWrite> LineWriter<W>

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

fn with_capacity(capacity: usize, inner: W) -> Self

Creates a new LineWriter with the specified buffer capacity.

fn buffer(&self) -> &[u8]

Returns a reference to buf_writer's internally buffered data.

fn get_ref(&self) -> &W

Acquires a reference to the underlying sink or stream that this combinator is pulling from.

Trait Implementations

impl<'__pin, W: AsyncWrite> Unpin for LineWriter<W> where PinnedFieldsOf<__Origin<'__pin, W>>: Unpin,

impl<W: AsyncWrite> AsyncWrite for LineWriter<W>

fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>]) -> Poll<Result<usize>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Forward to buf_writer 's BufWriter::poll_flush()

fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Forward to buf_writer 's BufWriter::poll_close()

impl<W: Debug + AsyncWrite> Debug for LineWriter<W>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<W> Freeze for LineWriter<W> where BufWriter<W>: Freeze,

impl<W> RefUnwindSafe for LineWriter<W> where BufWriter<W>: RefUnwindSafe,

impl<W> Send for LineWriter<W> where BufWriter<W>: Send,

impl<W> Sync for LineWriter<W> where BufWriter<W>: Sync,

impl<W> UnsafeUnpin for LineWriter<W> where BufWriter<W>: UnsafeUnpin,

impl<W> UnwindSafe for LineWriter<W> where BufWriter<W>: UnwindSafe,

Blanket Implementations

impl<T> Any for LineWriter<W> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for LineWriter<W> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for LineWriter<W> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for LineWriter<W>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for LineWriter<W> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for LineWriter<W> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for LineWriter<W> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W> AsyncWriteExt for LineWriter<W> where W: AsyncWrite + ?Sized,