Struct Reader

struct Reader<B> { ... }

A Buf adapter which implements io::Read for the inner value.

This struct is generally created by calling reader() on Buf. See documentation of reader() for more details.

Implementations

impl<B: Buf> Reader<B>

fn get_ref(self: &Self) -> &B

Gets a reference to the underlying Buf.

It is inadvisable to directly read from the underlying Buf.

Examples

use bytes::Buf;

let buf = b"hello world".reader();

assert_eq!(b"hello world", buf.get_ref());
fn get_mut(self: &mut Self) -> &mut B

Gets a mutable reference to the underlying Buf.

It is inadvisable to directly read from the underlying Buf.

fn into_inner(self: Self) -> B

Consumes this Reader, returning the underlying value.

Examples

use bytes::Buf;
use std::io;

let mut buf = b"hello world".reader();
let mut dst = vec![];

io::copy(&mut buf, &mut dst).unwrap();

let buf = buf.into_inner();
assert_eq!(0, buf.remaining());

impl<B> Freeze for Reader<B>

impl<B> RefUnwindSafe for Reader<B>

impl<B> Send for Reader<B>

impl<B> Sync for Reader<B>

impl<B> Unpin for Reader<B>

impl<B> UnsafeUnpin for Reader<B>

impl<B> UnwindSafe for Reader<B>

impl<B: $crate::fmt::Debug> Debug for Reader<B>

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

impl<B: Buf + Sized> BufRead for Reader<B>

fn fill_buf(self: &mut Self) -> Result<&[u8]>
fn consume(self: &mut Self, amt: usize)

impl<B: Buf + Sized> Read for Reader<B>

fn read(self: &mut Self, dst: &mut [u8]) -> Result<usize>

impl<T> Any for Reader<B>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Reader<B>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Reader<B>

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

impl<T> From for Reader<B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Reader<B>

fn into(self: 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 for Reader<B>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Reader<B>

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