bitcoin_io

Struct Take

source
pub struct Take<'a, R: Read + ?Sized> { /* private fields */ }
Expand description

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

Created by calling [Read::take].

Implementations§

source§

impl<'a, R: Read + ?Sized> Take<'a, R>

source

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

Available on crate feature alloc only.

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

Trait Implementations§

source§

impl<'a, R: BufRead + ?Sized> BufRead for Take<'a, R>

source§

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

Returns data read from this reader, filling the internal buffer if needed.
source§

fn consume(&mut self, amount: usize)

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

impl<'a, R: Read + ?Sized> Read for Take<'a, R>

source§

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

Reads bytes from source into buf.
source§

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

Reads bytes from source until buf is full.
source§

fn take(&mut self, limit: u64) -> Take<'_, Self>

Creates an adapter which will read at most limit bytes.
source§

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

Available on crate feature alloc only.
Attempts to read up to limit bytes from the reader, allocating space in buf as needed. Read more

Auto Trait Implementations§

§

impl<'a, R> Freeze for Take<'a, R>
where R: ?Sized,

§

impl<'a, R> RefUnwindSafe for Take<'a, R>
where R: RefUnwindSafe + ?Sized,

§

impl<'a, R> Send for Take<'a, R>
where R: Send + ?Sized,

§

impl<'a, R> Sync for Take<'a, R>
where R: Sync + ?Sized,

§

impl<'a, R> Unpin for Take<'a, R>
where R: ?Sized,

§

impl<'a, R> !UnwindSafe for Take<'a, R>

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.