Struct StreamReader
struct StreamReader<S, B> { ... }
Convert a Stream of byte chunks into an AsyncRead.
This type performs the inverse operation of ReaderStream.
This type also implements the AsyncBufRead trait, so you can use it
to read a Stream of byte chunks line-by-line. See the examples below.
Example
use Bytes;
use ;
use StreamReader;
#
# async
If the stream produces errors which are not std::io::Error,
the errors can be converted using StreamExt to map each
element.
use Bytes;
use AsyncReadExt;
use StreamReader;
use StreamExt;
#
# async
Using the AsyncBufRead impl, you can read a Stream of byte chunks
line-by-line. Note that you will usually also need to convert the error
type when doing this. See the second example for an explanation of how
to do this.
use ;
use StreamReader;
#
# async
Implementations
impl<S, B> StreamReader<S, B>
fn get_ref(self: &Self) -> &SGets a reference to the underlying stream.
It is inadvisable to directly read from the underlying stream.
fn get_mut(self: &mut Self) -> &mut SGets a mutable reference to the underlying stream.
It is inadvisable to directly read from the underlying stream.
fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S>Gets a pinned mutable reference to the underlying stream.
It is inadvisable to directly read from the underlying stream.
fn into_inner(self: Self) -> SConsumes this
BufWriter, returning the underlying stream.Note that any leftover data in the internal buffer is lost. If you additionally want access to the internal buffer use
into_inner_with_chunk.
impl<S, B, E> StreamReader<S, B>
fn new(stream: S) -> SelfConvert a stream of byte chunks into an
AsyncRead.The item should be a
Resultwith the ok variant being something that implements theBuftrait (e.g.Cursor<Vec<u8>>orBytes). The error should be convertible into an io error.fn into_inner_with_chunk(self: Self) -> (S, Option<B>)Consumes this
StreamReader, returning a Tuple consisting of the underlying stream and an Option of the internal buffer, which is Some in case the buffer contains elements.
impl<R> AsyncBufReadExt for StreamReader<S, B>
impl<R> AsyncReadExt for StreamReader<S, B>
impl<S, B> Freeze for StreamReader<S, B>
impl<S, B> RefUnwindSafe for StreamReader<S, B>
impl<S, B> Send for StreamReader<S, B>
impl<S, B> Sync for StreamReader<S, B>
impl<S, B> UnsafeUnpin for StreamReader<S, B>
impl<S, B> UnwindSafe for StreamReader<S, B>
impl<S, B, E> AsyncBufRead for StreamReader<S, B>
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>>fn consume(self: Pin<&mut Self>, amt: usize)
impl<S, B, E> AsyncRead for StreamReader<S, B>
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>
impl<S: $crate::fmt::Debug, B: $crate::fmt::Debug> Debug for StreamReader<S, B>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: Sink<T, Error = E>, B, E, T> Sink for StreamReader<S, B>
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), <Self as >::Error>>fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), <Self as >::Error>fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), <Self as >::Error>>fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), <Self as >::Error>>
impl<S: Unpin, B> Unpin for StreamReader<S, B>
impl<T> Any for StreamReader<S, B>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for StreamReader<S, B>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for StreamReader<S, B>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for StreamReader<S, B>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for StreamReader<S, B>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for StreamReader<S, B>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for StreamReader<S, B>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>