Struct Read

Source
pub struct Read { /* private fields */ }
Expand description

I/O-free coroutine for reading bytes into a buffer.

Implementations§

Source§

impl Read

Source

pub const DEFAULT_CAPACITY: usize = 8_192usize

The default read buffer capacity.

Source

pub fn new() -> Self

Creates a new coroutine to read bytes using a buffer with Self::DEFAULT_CAPACITY capacity.

See Self::with_capacity for a custom buffer capacity.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new coroutine to read bytes using a buffer with the given capacity.

Source

pub fn capacity(&self) -> usize

Returns the buffer capacity.

This function does not return directly the capacity of the buffer, it returns instead the initial capacity the coroutine was created with.

Source

pub fn shrink_to(&mut self, min_capacity: usize)

Shrinks the buffer to the given capacity.

Source

pub fn replace(&mut self, buffer: Vec<u8>)

Replaces the inner buffer with the given one.

Source

pub fn resume(&mut self, arg: Option<Io>) -> Result<Output, Io>

Makes the read progress.

Trait Implementations§

Source§

impl Debug for Read

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Read

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Read

§

impl RefUnwindSafe for Read

§

impl Send for Read

§

impl Sync for Read

§

impl Unpin for Read

§

impl UnwindSafe for Read

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.