pub struct ByteReader<R, E>where
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, E> ByteReader<R, E>where
R: Read,
E: Endianness,
impl<R, E> ByteReader<R, E>where
R: Read,
E: Endianness,
Sourcepub fn new(reader: R) -> ByteReader<R, E>
pub fn new(reader: R) -> ByteReader<R, E>
Wraps a ByteReader around something that implements Read
Sourcepub fn endian(reader: R, _endian: E) -> ByteReader<R, E>
pub fn endian(reader: R, _endian: E) -> ByteReader<R, E>
Wraps a ByteReader around something that implements Read
with the given endianness.
Sourcepub fn into_reader(self) -> R
pub fn into_reader(self) -> R
Unwraps internal reader and disposes of ByteReader.
Sourcepub fn into_bitreader(self) -> BitReader<R, E>
pub fn into_bitreader(self) -> BitReader<R, E>
Converts ByteReader to BitReader in the same endianness.
Trait Implementations§
Source§impl<R, E> ByteRead for ByteReader<R, E>where
R: Read,
E: Endianness,
impl<R, E> ByteRead for ByteReader<R, E>where
R: Read,
E: Endianness,
Source§fn read<V>(&mut self) -> Result<V, Error>where
V: Primitive,
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,
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<(), Error>
fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>
Completely fills the given buffer with whole bytes. Read more
Source§fn skip(&mut self, bytes: u32) -> Result<(), Error>
fn skip(&mut self, bytes: u32) -> Result<(), Error>
Skips the given number of bytes in the stream. Read more
Source§fn reader_ref(&mut self) -> &mut dyn Read
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], Error>
fn read_to_bytes<const SIZE: usize>(&mut self) -> Result<[u8; SIZE], Error>
👎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>, Error>
fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>, Error>
Completely fills a vector of bytes and returns it. Read more
Source§fn parse<F>(&mut self) -> Result<F, <F as FromByteStream>::Error>where
F: FromByteStream,
fn parse<F>(&mut self) -> Result<F, <F as FromByteStream>::Error>where
F: FromByteStream,
Parses and returns complex type
Source§fn parse_with<'a, F>(
&mut self,
context: &<F as FromByteStreamWith<'a>>::Context,
) -> Result<F, <F as FromByteStreamWith<'a>>::Error>where
F: FromByteStreamWith<'a>,
fn parse_with<'a, F>(
&mut self,
context: &<F as FromByteStreamWith<'a>>::Context,
) -> Result<F, <F as FromByteStreamWith<'a>>::Error>where
F: FromByteStreamWith<'a>,
Parses and returns complex type with context
Source§fn parse_using<F>(
&mut self,
context: <F as FromByteStreamUsing>::Context,
) -> Result<F, <F as FromByteStreamUsing>::Error>where
F: FromByteStreamUsing,
fn parse_using<F>(
&mut self,
context: <F as FromByteStreamUsing>::Context,
) -> Result<F, <F as FromByteStreamUsing>::Error>where
F: FromByteStreamUsing,
Parses and returns complex type with owned context
Source§impl<R, E> Debug for ByteReader<R, E>
impl<R, E> Debug for ByteReader<R, E>
Source§impl<R, E> Seek for ByteReader<R, E>
impl<R, E> Seek for ByteReader<R, E>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
Seek to an offset, in bytes, in a stream. Read more
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
🔬This is a nightly-only experimental API. (
seek_stream_len)Returns the length of this stream (in bytes). Read more
Auto Trait Implementations§
impl<R, E> Freeze for ByteReader<R, E>where
R: Freeze,
impl<R, E> RefUnwindSafe for ByteReader<R, E>where
R: RefUnwindSafe,
E: RefUnwindSafe,
impl<R, E> Send for ByteReader<R, E>
impl<R, E> Sync for ByteReader<R, E>
impl<R, E> Unpin for ByteReader<R, E>
impl<R, E> UnsafeUnpin for ByteReader<R, E>where
R: UnsafeUnpin,
impl<R, E> UnwindSafe for ByteReader<R, E>where
R: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more