[][src]Struct agilulf_protocol::AsyncReadBuffer

pub struct AsyncReadBuffer<T: AsyncRead + Unpin> { /* fields omitted */ }

A Read buffer to provide read_exact and read_line methods.

Amazingly there isn't an AsyncBuffer for latest futures! The implementation of this struct is similar with BufferReader in std. The implementation of read_exact and read_line learns from BufferRead trait in std.

Methods

impl<T: AsyncRead + Unpin> AsyncReadBuffer<T>[src]

pub fn new(stream: T) -> AsyncReadBuffer<T>[src]

pub async fn fill_buf<'_>(&'_ mut self) -> Result<&'_ [u8]>[src]

pub fn consume(&mut self, amt: usize)[src]

pub async fn read_line<'_>(&'_ mut self) -> Result<Vec<u8>>[src]

Note: The return value of this method contains "\r\n".

This method will find "\n" and check whether the former one byte is "\r". If it is, it will be consumed and return.

pub async fn read_exact<'_>(&'_ mut self, size: usize) -> Result<Vec<u8>>[src]

impl<T: AsyncRead + Unpin + 'static> AsyncReadBuffer<T>[src]

pub fn into_reply_stream(self) -> impl Stream<Item = Result<Reply>>[src]

Convert a AsyncReadBuffer into Stream<Item = Result<Reply>>.

The implementation of it is use futures::stream::unfold" and every time it will read one reply on this stream (with the help of read_exactandread_line`)

impl<T: AsyncRead + Unpin + 'static> AsyncReadBuffer<T>[src]

pub fn into_command_stream(self) -> impl Stream<Item = Result<Command>>[src]

Convert a AsyncReadBuffer into Stream<Item = Result<Command>>.

Auto Trait Implementations

impl<T> Send for AsyncReadBuffer<T> where
    T: Send

impl<T> Unpin for AsyncReadBuffer<T>

impl<T> Sync for AsyncReadBuffer<T> where
    T: Sync

impl<T> UnwindSafe for AsyncReadBuffer<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for AsyncReadBuffer<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,