pub struct ByteReader<R: Read, E: Endianness> { /* private fields */ }
Expand description

For reading aligned bytes from a stream of bytes in a given endianness.

This only reads aligned values and maintains no internal state.

Implementations§

source§

impl<R: Read, E: Endianness> ByteReader<R, E>

source

pub fn new(reader: R) -> ByteReader<R, E>

Wraps a ByteReader around something that implements Read

source

pub fn endian(reader: R, _endian: E) -> ByteReader<R, E>

Wraps a ByteReader around something that implements Read with the given endianness.

source

pub fn into_reader(self) -> R

Unwraps internal reader and disposes of ByteReader.

source

pub fn reader(&mut self) -> &mut R

Provides mutable reference to internal reader

source

pub fn into_bitreader(self) -> BitReader<R, E>

Converts ByteReader to BitReader in the same endianness.

source

pub fn bitreader(&mut self) -> BitReader<&mut R, E>

Provides temporary BitReader in the same endianness.

Warning

Any unread bits left over when BitReader is dropped are lost.

Trait Implementations§

source§

impl<R: Read, E: Endianness> ByteRead for ByteReader<R, E>

source§

fn read<V>(&mut self) -> Result<V, Error>
where V: Primitive,

Reads whole numeric value from stream Read more
source§

fn read_as<F, V>(&mut self) -> Result<V, Error>
where F: Endianness, V: Primitive,

Reads whole numeric value from stream in a potentially different endianness Read more
source§

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

Completely fills the given buffer with whole bytes. Read more
source§

fn skip(&mut self, bytes: u32) -> Result<()>

Skips the given number of bytes in the stream. Read more
source§

fn reader_ref(&mut self) -> &mut dyn Read

Returns mutable reference to underlying reader
source§

fn read_to_bytes<const SIZE: usize>(&mut self) -> Result<[u8; SIZE]>

👎Deprecated since 1.8.0: use read() method instead
Completely fills a whole buffer with bytes and returns it. Read more
source§

fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>>

Completely fills a vector of bytes and returns it. Read more
source§

fn parse<F: FromByteStream>(&mut self) -> Result<F, F::Error>

Parses and returns complex type
source§

fn parse_with<'a, F: FromByteStreamWith<'a>>( &mut self, context: &F::Context ) -> Result<F, F::Error>

Parses and returns complex type with context
source§

impl<R: Debug + Read, E: Debug + Endianness> Debug for ByteReader<R, E>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R, E> RefUnwindSafe for ByteReader<R, E>

§

impl<R, E> Send for ByteReader<R, E>
where E: Send, R: Send,

§

impl<R, E> Sync for ByteReader<R, E>
where E: Sync, R: Sync,

§

impl<R, E> Unpin for ByteReader<R, E>
where E: Unpin, R: Unpin,

§

impl<R, E> UnwindSafe for ByteReader<R, E>
where E: UnwindSafe, 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>,

§

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.