Reader

Struct Reader 

Source
pub struct Reader<'a, Input: Read> { /* private fields */ }
Expand description

Reader implements buffering for an std::io::Read object.

Consider using native Rust std::io::BufReader.

Implementations§

Source§

impl<'a, Input: Read> Reader<'a, Input>

Source

pub fn new(r: &'a mut Input) -> Self

new creates a reader with the default size buffer

Source

pub fn new_size(r: &'a mut Input, size: usize) -> Self

new_size returns a new Reader whose buffer has at least the specified size.

Source

pub fn size(&mut self) -> usize

size returns the size of the underlying buffer in bytes.

Source

pub fn reset(&mut self, r: &'a mut Input)

reset discards any buffered data, resets all state, and switches the buffered reader to read from r.

Source

pub fn peek(&mut self, n: usize) -> (&[u8], Option<Box<dyn Error>>)

peek returns the next n bytes without advancing the reader. The bytes stop being valid at the next read call. If peek returns fewer than n bytes, it also returns an error explaining why the read is short. The error is ERR_BUFFER_FULL if n is larger than b’s buffer size.

Calling peek prevents a UnreadByte or UnreadRune call from succeeding until the next read operation.

Source

pub fn buffered(&mut self) -> usize

buffered returns the number of bytes that can be read from the current buffer.

Auto Trait Implementations§

§

impl<'a, Input> Freeze for Reader<'a, Input>

§

impl<'a, Input> !RefUnwindSafe for Reader<'a, Input>

§

impl<'a, Input> !Send for Reader<'a, Input>

§

impl<'a, Input> !Sync for Reader<'a, Input>

§

impl<'a, Input> Unpin for Reader<'a, Input>

§

impl<'a, Input> !UnwindSafe for Reader<'a, Input>

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.