pub struct RandomAccessBinReader { /* private fields */ }Trait Implementations§
Source§impl AsRef<[u8]> for RandomAccessBinReader
impl AsRef<[u8]> for RandomAccessBinReader
Source§impl<'r> BinReader<'r> for RandomAccessBinReader
impl<'r> BinReader<'r> for RandomAccessBinReader
Source§fn from_slice_with_offset(
slice: &[u8],
initial_offset: usize,
endidness: Endidness,
) -> Result<Self>
fn from_slice_with_offset( slice: &[u8], initial_offset: usize, endidness: Endidness, ) -> Result<Self>
Generates a new
BinReader using the provided slice, initial offset, and endidness. While
the exact implementation of this varies from implementation to implementation,
OwnableBinReaders will, more than likely, copy the data in the slice.Source§fn initial_offset(&self) -> usize
fn initial_offset(&self) -> usize
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Checks whether or not there is any data left, based off of the
BinReader::current_offset.Source§fn size(&self) -> usize
fn size(&self) -> usize
The amount of data in the reader. If the reader’s size changes (which none of the
implementations currently do), then this should return how much data was initially in the
reader.
Source§fn remaining(&self) -> usize
fn remaining(&self) -> usize
The amount of data left, based off of the
BinReader::current_offset.Source§fn current_offset(&self) -> usize
fn current_offset(&self) -> usize
The current offset of the reader’s cursor.
Source§fn change_endidness(&mut self, endidness: Endidness)
fn change_endidness(&mut self, endidness: Endidness)
Changes the default endidness.
Source§fn advance_to(&self, offset: usize) -> Result<()>
fn advance_to(&self, offset: usize) -> Result<()>
Sets the reader’s
BinReader::current_offset.Source§fn advance_by(&self, bytes: isize) -> Result<()>
fn advance_by(&self, bytes: isize) -> Result<()>
Alters the
BinReader::current_offset by the given amount.Source§fn next_n_bytes(&self, num_bytes: usize) -> Result<Bytes>
fn next_n_bytes(&self, num_bytes: usize) -> Result<Bytes>
Returns a
Bytes object of the requested size containing the next n bytes (where n is
the num_bytes parameter) and then advances the cursor by that much.Source§fn from_slice(slice: &'r [u8], endidness: Endidness) -> Result<Self>
fn from_slice(slice: &'r [u8], endidness: Endidness) -> Result<Self>
Functions the same as the
BinReader::from_slice_with_offset, except the initial offset
is always 0.Source§fn lower_offset_limit(&self) -> usize
fn lower_offset_limit(&self) -> usize
The lowest valid offset that can be requested. By default, this is the same as
BinReader::initial_offset.Source§fn upper_offset_limit(&self) -> usize
fn upper_offset_limit(&self) -> usize
The highest valid offset that can be requested. By default, this is the reader’s
BinReader::size plus its BinReader::initial_offset.Source§fn validate_offset(&self, offset: usize, size: usize) -> Result<()>
fn validate_offset(&self, offset: usize, size: usize) -> Result<()>
A helper method that validates an offset (mostly used by reader implementations). Read more
Source§fn relative_offset(&self, abs_offset: usize) -> Result<usize>
fn relative_offset(&self, abs_offset: usize) -> Result<usize>
Takes an absolute offset and converts it to a relative offset, based off of the
BinReader::current_offset.Source§fn next_bytes_are(&self, prefix: &[u8]) -> Result<bool>
fn next_bytes_are(&self, prefix: &[u8]) -> Result<bool>
Returns
true if the next bytes are the same as the ones provided.Source§fn bytes_at(&self, offset: usize, buf: &mut [u8]) -> Result<()>
fn bytes_at(&self, offset: usize, buf: &mut [u8]) -> Result<()>
Fills the provided buffer with bytes, starting at the provided offset. This does not alter
the
BinReader::current_offset.Source§fn subseq(&self, offset: usize, num_bytes: usize) -> Result<&[u8]>
fn subseq(&self, offset: usize, num_bytes: usize) -> Result<&[u8]>
Returns a subsequence (i.e. a
&[u8]) of data of the requested size beginning at the
provided offset.Source§fn range(&self, start: usize, end: usize) -> Result<&[u8]>
fn range(&self, start: usize, end: usize) -> Result<&[u8]>
Returns a slice of the data between the provided starting and ending offsets.
Source§fn next_bytes(&self, buf: &mut [u8]) -> Result<()>
fn next_bytes(&self, buf: &mut [u8]) -> Result<()>
Fills the provided buffer with the next n bytes, where n is the length of the buffer. This
then advances the
BinReader::current_offset by n.Source§fn current_u8(&self) -> Result<u8>
fn current_u8(&self) -> Result<u8>
Source§fn current_i8_ne(&self) -> Result<i8>
fn current_i8_ne(&self) -> Result<i8>
Gets the nelong endian
i8 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u16_be(&self) -> Result<u16>
fn current_u16_be(&self) -> Result<u16>
Gets the belong endian
u16 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u16_le(&self) -> Result<u16>
fn current_u16_le(&self) -> Result<u16>
Gets the lelong endian
u16 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i16_be(&self) -> Result<i16>
fn current_i16_be(&self) -> Result<i16>
Gets the belong endian
i16 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i16_le(&self) -> Result<i16>
fn current_i16_le(&self) -> Result<i16>
Gets the lelong endian
i16 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u32_be(&self) -> Result<u32>
fn current_u32_be(&self) -> Result<u32>
Gets the belong endian
u32 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u32_le(&self) -> Result<u32>
fn current_u32_le(&self) -> Result<u32>
Gets the lelong endian
u32 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i32_be(&self) -> Result<i32>
fn current_i32_be(&self) -> Result<i32>
Gets the belong endian
i32 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i32_le(&self) -> Result<i32>
fn current_i32_le(&self) -> Result<i32>
Gets the lelong endian
i32 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u64_be(&self) -> Result<u64>
fn current_u64_be(&self) -> Result<u64>
Gets the belong endian
u64 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u64_le(&self) -> Result<u64>
fn current_u64_le(&self) -> Result<u64>
Gets the lelong endian
u64 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i64_be(&self) -> Result<i64>
fn current_i64_be(&self) -> Result<i64>
Gets the belong endian
i64 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i64_le(&self) -> Result<i64>
fn current_i64_le(&self) -> Result<i64>
Gets the lelong endian
i64 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u128_be(&self) -> Result<u128>
fn current_u128_be(&self) -> Result<u128>
Gets the belong endian
u128 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_u128_le(&self) -> Result<u128>
fn current_u128_le(&self) -> Result<u128>
Gets the lelong endian
u128 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i128_be(&self) -> Result<i128>
fn current_i128_be(&self) -> Result<i128>
Gets the belong endian
i128 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn current_i128_le(&self) -> Result<i128>
fn current_i128_le(&self) -> Result<i128>
Gets the lelong endian
i128 at the BinReader::current_offset without
altering the BinReader::current_offset.Source§fn u8_at(&self, offset: usize) -> Result<u8>
fn u8_at(&self, offset: usize) -> Result<u8>
Gets the
u8 at the provided offset without altering the BinReader::current_offset.Source§fn i8_ne_at(&self, offset: usize) -> Result<i8>
fn i8_ne_at(&self, offset: usize) -> Result<i8>
Gets the nelong endian
i8 at the provided offset without altering the
BinReader::current_offset.Source§fn u16_be_at(&self, offset: usize) -> Result<u16>
fn u16_be_at(&self, offset: usize) -> Result<u16>
Gets the belong endian
u16 at the provided offset without altering the
BinReader::current_offset.Source§fn u16_le_at(&self, offset: usize) -> Result<u16>
fn u16_le_at(&self, offset: usize) -> Result<u16>
Gets the lelong endian
u16 at the provided offset without altering the
BinReader::current_offset.Source§fn i16_be_at(&self, offset: usize) -> Result<i16>
fn i16_be_at(&self, offset: usize) -> Result<i16>
Gets the belong endian
i16 at the provided offset without altering the
BinReader::current_offset.Source§fn i16_le_at(&self, offset: usize) -> Result<i16>
fn i16_le_at(&self, offset: usize) -> Result<i16>
Gets the lelong endian
i16 at the provided offset without altering the
BinReader::current_offset.Source§fn u32_be_at(&self, offset: usize) -> Result<u32>
fn u32_be_at(&self, offset: usize) -> Result<u32>
Gets the belong endian
u32 at the provided offset without altering the
BinReader::current_offset.Source§fn u32_le_at(&self, offset: usize) -> Result<u32>
fn u32_le_at(&self, offset: usize) -> Result<u32>
Gets the lelong endian
u32 at the provided offset without altering the
BinReader::current_offset.Source§fn i32_be_at(&self, offset: usize) -> Result<i32>
fn i32_be_at(&self, offset: usize) -> Result<i32>
Gets the belong endian
i32 at the provided offset without altering the
BinReader::current_offset.Source§fn i32_le_at(&self, offset: usize) -> Result<i32>
fn i32_le_at(&self, offset: usize) -> Result<i32>
Gets the lelong endian
i32 at the provided offset without altering the
BinReader::current_offset.Source§fn u64_be_at(&self, offset: usize) -> Result<u64>
fn u64_be_at(&self, offset: usize) -> Result<u64>
Gets the belong endian
u64 at the provided offset without altering the
BinReader::current_offset.Source§fn u64_le_at(&self, offset: usize) -> Result<u64>
fn u64_le_at(&self, offset: usize) -> Result<u64>
Gets the lelong endian
u64 at the provided offset without altering the
BinReader::current_offset.Source§fn i64_be_at(&self, offset: usize) -> Result<i64>
fn i64_be_at(&self, offset: usize) -> Result<i64>
Gets the belong endian
i64 at the provided offset without altering the
BinReader::current_offset.Source§fn i64_le_at(&self, offset: usize) -> Result<i64>
fn i64_le_at(&self, offset: usize) -> Result<i64>
Gets the lelong endian
i64 at the provided offset without altering the
BinReader::current_offset.Source§fn u128_be_at(&self, offset: usize) -> Result<u128>
fn u128_be_at(&self, offset: usize) -> Result<u128>
Gets the belong endian
u128 at the provided offset without altering the
BinReader::current_offset.Source§fn u128_le_at(&self, offset: usize) -> Result<u128>
fn u128_le_at(&self, offset: usize) -> Result<u128>
Gets the lelong endian
u128 at the provided offset without altering the
BinReader::current_offset.Source§fn i128_be_at(&self, offset: usize) -> Result<i128>
fn i128_be_at(&self, offset: usize) -> Result<i128>
Gets the belong endian
i128 at the provided offset without altering the
BinReader::current_offset.Source§fn i128_le_at(&self, offset: usize) -> Result<i128>
fn i128_le_at(&self, offset: usize) -> Result<i128>
Gets the lelong endian
i128 at the provided offset without altering the
BinReader::current_offset.Source§fn u16_at(&self, offset: usize) -> Result<u16>
fn u16_at(&self, offset: usize) -> Result<u16>
Gets the
u16 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn u32_at(&self, offset: usize) -> Result<u32>
fn u32_at(&self, offset: usize) -> Result<u32>
Gets the
u32 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn u64_at(&self, offset: usize) -> Result<u64>
fn u64_at(&self, offset: usize) -> Result<u64>
Gets the
u64 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn u128_at(&self, offset: usize) -> Result<u128>
fn u128_at(&self, offset: usize) -> Result<u128>
Gets the
u128 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn i16_at(&self, offset: usize) -> Result<i16>
fn i16_at(&self, offset: usize) -> Result<i16>
Gets the
i16 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn i32_at(&self, offset: usize) -> Result<i32>
fn i32_at(&self, offset: usize) -> Result<i32>
Gets the
i32 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn i64_at(&self, offset: usize) -> Result<i64>
fn i64_at(&self, offset: usize) -> Result<i64>
Gets the
i64 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn i128_at(&self, offset: usize) -> Result<i128>
fn i128_at(&self, offset: usize) -> Result<i128>
Gets the
i128 using the default endidness at the provided offset without altering the
BinReader::current_offset. If the current endidness is Endidness::Unknown, then an
error is returned.Source§fn next_i8_ne(&self) -> Result<i8>
fn next_i8_ne(&self) -> Result<i8>
Source§fn next_u16_be(&self) -> Result<u16>
fn next_u16_be(&self) -> Result<u16>
Source§fn next_u16_le(&self) -> Result<u16>
fn next_u16_le(&self) -> Result<u16>
Source§fn next_i16_be(&self) -> Result<i16>
fn next_i16_be(&self) -> Result<i16>
Source§fn next_i16_le(&self) -> Result<i16>
fn next_i16_le(&self) -> Result<i16>
Source§fn next_u32_be(&self) -> Result<u32>
fn next_u32_be(&self) -> Result<u32>
Source§fn next_u32_le(&self) -> Result<u32>
fn next_u32_le(&self) -> Result<u32>
Source§fn next_i32_be(&self) -> Result<i32>
fn next_i32_be(&self) -> Result<i32>
Source§fn next_i32_le(&self) -> Result<i32>
fn next_i32_le(&self) -> Result<i32>
Source§fn next_u64_be(&self) -> Result<u64>
fn next_u64_be(&self) -> Result<u64>
Source§fn next_u64_le(&self) -> Result<u64>
fn next_u64_le(&self) -> Result<u64>
Source§fn next_i64_be(&self) -> Result<i64>
fn next_i64_be(&self) -> Result<i64>
Source§fn next_i64_le(&self) -> Result<i64>
fn next_i64_le(&self) -> Result<i64>
Source§fn next_u128_be(&self) -> Result<u128>
fn next_u128_be(&self) -> Result<u128>
Source§fn next_u128_le(&self) -> Result<u128>
fn next_u128_le(&self) -> Result<u128>
Source§fn next_i128_be(&self) -> Result<i128>
fn next_i128_be(&self) -> Result<i128>
Source§fn next_i128_le(&self) -> Result<i128>
fn next_i128_le(&self) -> Result<i128>
Source§fn next_u16(&self) -> Result<u16>
fn next_u16(&self) -> Result<u16>
Gets the
u16 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_u32(&self) -> Result<u32>
fn next_u32(&self) -> Result<u32>
Gets the
u16 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_u64(&self) -> Result<u64>
fn next_u64(&self) -> Result<u64>
Gets the
u16 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_u128(&self) -> Result<u128>
fn next_u128(&self) -> Result<u128>
Gets the
u16 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_i8(&self) -> Result<i8>
fn next_i8(&self) -> Result<i8>
Gets the
i8 at the BinReader::current_offset and then advances it by 1. If the
current endidness is Endidness::Unknown, then an error is returned.Source§fn next_i16(&self) -> Result<i16>
fn next_i16(&self) -> Result<i16>
Gets the
i16 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_i32(&self) -> Result<i32>
fn next_i32(&self) -> Result<i32>
Gets the
i32 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_i64(&self) -> Result<i64>
fn next_i64(&self) -> Result<i64>
Gets the
i64 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§fn next_i128(&self) -> Result<i128>
fn next_i128(&self) -> Result<i128>
Gets the
i128 using the default endidness at the BinReader::current_offset and then
advances it by 1. If the current endidness is Endidness::Unknown, then an error is
returned.Source§impl Borrow<[u8]> for RandomAccessBinReader
impl Borrow<[u8]> for RandomAccessBinReader
Source§impl BufRead for RandomAccessBinReader
impl BufRead for RandomAccessBinReader
Source§fn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data, via
Read methods, if empty. Read moreSource§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
Marks the given
amount of additional bytes from the internal buffer as having been read.
Subsequent calls to read only return bytes that have not been marked as read. Read moreSource§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
🔬This is a nightly-only experimental API. (
buf_read_has_data_left)Checks if there is any data left to be
read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
Skips all bytes until the delimiter
byte or EOF is reached. Read more1.0.0 · Source§fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until a newline (the
0xA byte) is reached, and append
them to the provided String buffer. Read moreSource§impl<'r> OwnableBinReader<'r> for RandomAccessBinReader
impl<'r> OwnableBinReader<'r> for RandomAccessBinReader
fn from_file_with_offset<P: AsRef<Path>>( path: P, initial_offset: usize, endidness: Endidness, ) -> Result<Self>
fn from_bytes_with_offset( bytes: Bytes, initial_offset: usize, endidness: Endidness, ) -> Result<Self>
fn from_file<P: AsRef<Path>>(path: P, endidness: Endidness) -> Result<Self>
fn from_bytes(bytes: Bytes, endidness: Endidness) -> Result<Self>
Source§impl Read for RandomAccessBinReader
impl Read for RandomAccessBinReader
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
Reads all bytes until EOF in this source, placing them into
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until EOF in this source, appending them to
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Reads the exact number of bytes required to fill
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Reads the exact number of bytes required to fill
cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adaptor for this instance of
Read. Read moreSource§impl Seek for RandomAccessBinReader
impl Seek for RandomAccessBinReader
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
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
Source§impl<'r> SliceableBinReader<'r> for RandomAccessBinReader
impl<'r> SliceableBinReader<'r> for RandomAccessBinReader
fn slice_reader( &self, start: usize, end: usize, ) -> Result<SliceRefBinReader<'_>>
fn next_n_bytes_as_reader( &self, num_bytes: usize, ) -> Result<SliceRefBinReader<'_>>
fn next_n_bytes_as_reader_retain_offset( &mut self, num_bytes: usize, ) -> Result<SliceRefBinReader<'_>>
fn slice_reader_with_offset( &self, start: usize, offset: usize, end: usize, ) -> Result<SliceRefBinReader<'_>>
fn slice_reader_retain_offset( &self, start: usize, end: usize, ) -> Result<SliceRefBinReader<'_>>
Auto Trait Implementations§
impl !Freeze for RandomAccessBinReader
impl !RefUnwindSafe for RandomAccessBinReader
impl Send for RandomAccessBinReader
impl !Sync for RandomAccessBinReader
impl Unpin for RandomAccessBinReader
impl UnwindSafe for RandomAccessBinReader
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