Take

Struct Take 

Source
pub struct Take<R> { /* private fields */ }
Expand description

Reader adapter which limits the bytes read from an underlying reader.

Created by calling [Read::take].

Implementations§

Source§

impl<R: Read> Take<R>

Source

pub fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Reads all bytes until EOF from the underlying reader into buf.

Allocates space in buf as needed.

§Returns

The number of bytes read if successful or an Error if reading fails.

Trait Implementations§

Source§

impl<R: BufRead> BufRead for Take<R>

Source§

fn fill_buf(&mut self) -> Result<&[u8]>

Returns data read from this reader, filling the internal buffer if needed. Read more
Source§

fn consume(&mut self, amount: usize)

Marks the buffered data up to amount as consumed. Read more
Source§

impl<R: Debug> Debug for Take<R>

Source§

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

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

impl<R: Read> Read for Take<R>

Source§

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

Reads bytes from source into buf. Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Reads bytes from source until buf is full. Read more
Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Constructs a new adapter which will read at most limit bytes.
Source§

fn read_to_limit(&mut self, buf: &mut Vec<u8>, limit: u64) -> Result<usize>

Attempts to read up to limit bytes from the reader, allocating space in buf as needed. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Take<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Take<R>
where R: RefUnwindSafe,

§

impl<R> Send for Take<R>
where R: Send,

§

impl<R> Sync for Take<R>
where R: Sync,

§

impl<R> Unpin for Take<R>
where R: Unpin,

§

impl<R> UnwindSafe for Take<R>
where R: UnwindSafe,

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.