pub struct BufReader<'a> { /* private fields */ }
Expand description

A BufReader reads bytes from a byte buffer.

Implementations§

source§

impl<'a> BufReader<'a>

source

pub fn new(buf: &'a [u8]) -> Self

Instantiate a new BufReader with a given byte buffer.

source

pub fn scan_bytes_ref( &mut self, pattern: &[u8], scan_len: usize ) -> Result<&'a [u8]>

Scans up-to scan_len bytes from the stream until a byte pattern is matched. A reference to scanned bytes including the matched pattern are returned. If scan_len bytes are scanned without matching the pattern, a reference to the scanned bytes are also returned. Likewise, if the underlying buffer is exhausted before matching the pattern, remainder of the buffer is returned.

source

pub fn scan_bytes_aligned_ref( &mut self, pattern: &[u8], align: usize, scan_len: usize ) -> Result<&'a [u8]>

Scans up-to scan_len bytes from the stream until a byte pattern is matched on the specified byte alignment boundary. Operation is otherwise identical to scan_bytes_ref.

source

pub fn read_buf_bytes_ref(&mut self, len: usize) -> Result<&'a [u8]>

Returns a reference to the next len bytes in the buffer and advances the stream.

source

pub fn read_buf_bytes_available_ref(&mut self) -> &'a [u8]

Returns a reference to the remaining bytes in the buffer and advances the stream to the end.

Trait Implementations§

source§

impl<'a> FiniteStream for BufReader<'a>

source§

fn byte_len(&self) -> u64

Returns the length of the the stream in bytes.
source§

fn bytes_read(&self) -> u64

Returns the number of bytes that have been read.
source§

fn bytes_available(&self) -> u64

Returns the number of bytes available for reading.
source§

impl<'a> ReadBytes for BufReader<'a>

source§

fn read_byte(&mut self) -> Result<u8>

Reads a single byte from the stream and returns it or an error.
source§

fn read_double_bytes(&mut self) -> Result<[u8; 2]>

Reads two bytes from the stream and returns them in read-order or an error.
source§

fn read_triple_bytes(&mut self) -> Result<[u8; 3]>

Reads three bytes from the stream and returns them in read-order or an error.
source§

fn read_quad_bytes(&mut self) -> Result<[u8; 4]>

Reads four bytes from the stream and returns them in read-order or an error.
source§

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

Reads up-to the number of bytes required to fill buf or returns an error.
source§

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

Reads exactly the number of bytes required to fill be provided buffer or returns an error.
source§

fn scan_bytes_aligned<'b>( &mut self, pattern: &[u8], align: usize, buf: &'b mut [u8] ) -> Result<&'b mut [u8]>

Reads bytes from a stream into a supplied buffer until a byte patter is matched on an aligned byte boundary. Returns a mutable slice to the valid region of the provided buffer.
source§

fn ignore_bytes(&mut self, count: u64) -> Result<()>

Ignores the specified number of bytes from the stream or returns an error.
source§

fn pos(&self) -> u64

Gets the position of the stream.
source§

fn read_u8(&mut self) -> Result<u8>

Reads a single unsigned byte from the stream and returns it or an error.
source§

fn read_i8(&mut self) -> Result<i8>

Reads a single signed byte from the stream and returns it or an error.
source§

fn read_u16(&mut self) -> Result<u16>

Reads two bytes from the stream and interprets them as an unsigned 16-bit little-endian integer or returns an error.
source§

fn read_i16(&mut self) -> Result<i16>

Reads two bytes from the stream and interprets them as an signed 16-bit little-endian integer or returns an error.
source§

fn read_be_u16(&mut self) -> Result<u16>

Reads two bytes from the stream and interprets them as an unsigned 16-bit big-endian integer or returns an error.
source§

fn read_be_i16(&mut self) -> Result<i16>

Reads two bytes from the stream and interprets them as an signed 16-bit big-endian integer or returns an error.
source§

fn read_u24(&mut self) -> Result<u32>

Reads three bytes from the stream and interprets them as an unsigned 24-bit little-endian integer or returns an error.
source§

fn read_i24(&mut self) -> Result<i32>

Reads three bytes from the stream and interprets them as an signed 24-bit little-endian integer or returns an error.
source§

fn read_be_u24(&mut self) -> Result<u32>

Reads three bytes from the stream and interprets them as an unsigned 24-bit big-endian integer or returns an error.
source§

fn read_be_i24(&mut self) -> Result<i32>

Reads three bytes from the stream and interprets them as an signed 24-bit big-endian integer or returns an error.
source§

fn read_u32(&mut self) -> Result<u32>

Reads four bytes from the stream and interprets them as an unsigned 32-bit little-endian integer or returns an error.
source§

fn read_i32(&mut self) -> Result<i32>

Reads four bytes from the stream and interprets them as an signed 32-bit little-endian integer or returns an error.
source§

fn read_be_u32(&mut self) -> Result<u32>

Reads four bytes from the stream and interprets them as an unsigned 32-bit big-endian integer or returns an error.
source§

fn read_be_i32(&mut self) -> Result<i32>

Reads four bytes from the stream and interprets them as a signed 32-bit big-endian integer or returns an error.
source§

fn read_u64(&mut self) -> Result<u64>

Reads eight bytes from the stream and interprets them as an unsigned 64-bit little-endian integer or returns an error.
source§

fn read_i64(&mut self) -> Result<i64>

Reads eight bytes from the stream and interprets them as an signed 64-bit little-endian integer or returns an error.
source§

fn read_be_u64(&mut self) -> Result<u64>

Reads eight bytes from the stream and interprets them as an unsigned 64-bit big-endian integer or returns an error.
source§

fn read_be_i64(&mut self) -> Result<i64>

Reads eight bytes from the stream and interprets them as an signed 64-bit big-endian integer or returns an error.
source§

fn read_f32(&mut self) -> Result<f32>

Reads four bytes from the stream and interprets them as a 32-bit little-endian IEEE-754 floating-point value.
source§

fn read_be_f32(&mut self) -> Result<f32>

Reads four bytes from the stream and interprets them as a 32-bit big-endian IEEE-754 floating-point value.
source§

fn read_f64(&mut self) -> Result<f64>

Reads four bytes from the stream and interprets them as a 64-bit little-endian IEEE-754 floating-point value.
source§

fn read_be_f64(&mut self) -> Result<f64>

Reads four bytes from the stream and interprets them as a 64-bit big-endian IEEE-754 floating-point value.
source§

fn read_boxed_slice(&mut self, len: usize) -> Result<Box<[u8]>>

Reads up-to the number of bytes requested, and returns a boxed slice of the data or an error.
source§

fn read_boxed_slice_exact(&mut self, len: usize) -> Result<Box<[u8]>>

Reads exactly the number of bytes requested, and returns a boxed slice of the data or an error.
source§

fn scan_bytes<'a>( &mut self, pattern: &[u8], buf: &'a mut [u8] ) -> Result<&'a mut [u8]>

Reads bytes from the stream into a supplied buffer until a byte pattern is matched. Returns a mutable slice to the valid region of the provided buffer.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for BufReader<'a>

§

impl<'a> Send for BufReader<'a>

§

impl<'a> Sync for BufReader<'a>

§

impl<'a> Unpin for BufReader<'a>

§

impl<'a> UnwindSafe for BufReader<'a>

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

source§

fn into_sample(self) -> T

source§

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

§

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>,

§

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.