Skip to main content

BinaryReader

Struct BinaryReader 

Source
pub struct BinaryReader<R, O = BigEndian> { /* private fields */ }
Expand description

Reader wrapper for fixed-width binary values.

The byte order is selected by the O type parameter. Use BinaryReader<R, BigEndian> for big-endian data and BinaryReader<R, LittleEndian> for little-endian data.

If a synchronous read fails partway through a value, some bytes may already be consumed. Do not blindly retry; use an outer framing boundary or a trusted seek checkpoint to recover.

§Type Parameters

  • R: Underlying byte input.
  • O: Compile-time byte-order specification.

§Examples

use qubit_codec::BigEndian;
use qubit_io_binary::BinaryReader;
use std::io::Cursor;

let mut reader = BinaryReader::<_, BigEndian>::new(Cursor::new([0x12, 0x34]));
assert_eq!(reader.read_u16()?, 0x1234);

Implementations§

Source§

impl<R, O> BinaryReader<R, O>
where R: ByteInput,

Source

pub fn is_buffered(&self) -> bool

Returns whether this reader buffers input.

§Returns

Returns true when reads may prefetch bytes into an internal buffer.

Source

pub unsafe fn read_unchecked( &mut self, output: &mut [u8], index: usize, count: usize, ) -> Result<usize>

Reads up to count bytes into an indexed output range.

§Parameters
  • output: Destination byte buffer.
  • index: Start of the writable range.
  • count: Maximum number of bytes to read.
§Returns

Returns the number of bytes read; a successful read may be short. For a non-empty request, Ok(0) means no bytes were available in this call or the input reached its end; it does not promise permanent EOF. A successful empty request returns zero without establishing EOF. Empty requests may still call the underlying input or return an error. See qubit_io::Input::read_unchecked for the underlying contract.

§Errors

Returns the underlying input error.

§Safety

index..index + count must be a valid range within output.

Source

pub fn read(&mut self, output: &mut [u8]) -> Result<usize>

Reads bytes into the full output slice.

§Parameters
  • output: Destination byte buffer.
§Returns

Returns the number of bytes read; a successful read may be short. For a non-empty request, Ok(0) means no bytes were available in this call or the input reached its end; it does not promise permanent EOF. A successful empty request returns zero without establishing EOF. Empty requests may still call the underlying input or return an error. See qubit_io::Input::read for the underlying contract.

§Errors

Returns the underlying input error.

Source

pub unsafe fn read_fully_unchecked( &mut self, output: &mut [u8], index: usize, count: usize, ) -> Result<usize>

Reads bytes into an indexed range until it is full or a read returns zero.

§Parameters
  • output: Destination byte buffer.
  • index: Start of the writable range.
  • count: Maximum number of bytes to read.
§Returns

Returns the number of bytes read before the range is full or a read returns zero.

§Errors

Returns the underlying input error.

§Safety

index..index + count must be a valid range within output.

Source

pub fn read_fully(&mut self, output: &mut [u8]) -> Result<usize>

Reads bytes into the full output slice until it is full or a read returns zero.

§Parameters
  • output: Destination byte buffer.
§Returns

Returns the number of bytes read before the slice is full or a read returns zero.

§Errors

Returns the underlying input error.

Source

pub fn read_exactly(&mut self, output: &mut [u8]) -> Result<()>

Reads bytes until the full output slice is filled.

§Parameters
  • output: Destination byte buffer.
§Errors

Returns the underlying input error, including an unexpected-EOF error when the slice cannot be filled.

Source§

impl<R, O> BinaryReader<R, O>

Source

pub fn seek_to(&mut self, position: SeekFrom) -> Result<u64>

Seeks the wrapped byte stream; see Seekable::seek_to for the seek contract. Buffered wrappers interpret relative offsets and report positions relative to their logical stream position. A position query does not flush buffered output.

§Parameters
  • position: Relative or absolute target position.
§Returns

Returns the resulting stream position in bytes. For buffered wrappers this is the logical position, including buffered data.

§Errors

Returns the underlying seek error.

Source§

impl<R, O> BinaryReader<R, O>
where O: ByteOrderSpec,

Source

pub const fn new(inner: R) -> Self

Creates a binary reader.

§Parameters
  • inner: Underlying byte reader.
§Returns

Returns a reader using the byte order selected by O.

Source

pub const fn byte_order(&self) -> ByteOrder

Returns the byte order selected by this reader.

§Returns

Returns the compile-time byte order as a runtime value.

Source

pub const fn inner(&self) -> &R

Returns a shared reference to the underlying reader.

§Returns

Returns the wrapped reader.

Source

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

Returns an exclusive reference to the underlying reader.

§Returns

Returns mutable access to the wrapped reader.

Source

pub fn into_inner(self) -> R

Consumes this wrapper and returns the underlying reader.

§Returns

Returns the wrapped reader.

Source§

impl<R> BinaryReader<R, BigEndian>
where R: ByteInput,

Source

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

Reads an unsigned 8-bit integer.

§Returns

Returns the decoded u8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 8-bit integer.

§Returns

Returns the decoded i8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 16-bit integer.

§Returns

Returns the decoded u16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 32-bit integer.

§Returns

Returns the decoded u32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 64-bit integer.

§Returns

Returns the decoded u64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_u128(&mut self) -> Result<u128>

Reads an unsigned 128-bit integer.

§Returns

Returns the decoded u128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 16-bit integer.

§Returns

Returns the decoded i16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 32-bit integer.

§Returns

Returns the decoded i32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 64-bit integer.

§Returns

Returns the decoded i64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_i128(&mut self) -> Result<i128>

Reads a signed 128-bit integer.

§Returns

Returns the decoded i128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 32-bit float.

§Returns

Returns the decoded f32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 64-bit float.

§Returns

Returns the decoded f64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_string_with_u16_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 16-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Source

pub fn read_string_with_u32_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 32-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input, conversion, or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Source§

impl<R> BinaryReader<R, LittleEndian>
where R: ByteInput,

Source

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

Reads an unsigned 8-bit integer.

§Returns

Returns the decoded u8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 8-bit integer.

§Returns

Returns the decoded i8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 16-bit integer.

§Returns

Returns the decoded u16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 32-bit integer.

§Returns

Returns the decoded u32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 64-bit integer.

§Returns

Returns the decoded u64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_u128(&mut self) -> Result<u128>

Reads an unsigned 128-bit integer.

§Returns

Returns the decoded u128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 16-bit integer.

§Returns

Returns the decoded i16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 32-bit integer.

§Returns

Returns the decoded i32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 64-bit integer.

§Returns

Returns the decoded i64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_i128(&mut self) -> Result<i128>

Reads a signed 128-bit integer.

§Returns

Returns the decoded i128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 32-bit float.

§Returns

Returns the decoded f32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 64-bit float.

§Returns

Returns the decoded f64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_string_with_u16_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 16-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Source

pub fn read_string_with_u32_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 32-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input, conversion, or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Source§

impl<R> BinaryReader<R, NativeEndian>
where R: ByteInput,

Source

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

Reads an unsigned 8-bit integer.

§Returns

Returns the decoded u8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 8-bit integer.

§Returns

Returns the decoded i8.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 16-bit integer.

§Returns

Returns the decoded u16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 32-bit integer.

§Returns

Returns the decoded u32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads an unsigned 64-bit integer.

§Returns

Returns the decoded u64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_u128(&mut self) -> Result<u128>

Reads an unsigned 128-bit integer.

§Returns

Returns the decoded u128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 16-bit integer.

§Returns

Returns the decoded i16.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 32-bit integer.

§Returns

Returns the decoded i32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a signed 64-bit integer.

§Returns

Returns the decoded i64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_i128(&mut self) -> Result<i128>

Reads a signed 128-bit integer.

§Returns

Returns the decoded i128.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 32-bit float.

§Returns

Returns the decoded f32.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

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

Reads a 64-bit float.

§Returns

Returns the decoded f64.

§Errors

Returns an input error, including an unexpected-end-of-input error when the scalar is truncated.

Source

pub fn read_string_with_u16_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 16-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Source

pub fn read_string_with_u32_len(&mut self, max_len: usize) -> Result<String>

Reads a UTF-8 string prefixed by a 32-bit byte length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
§Returns

Returns the decoded UTF-8 string.

§Errors

Returns an input, conversion, or allocation error, or std::io::ErrorKind::InvalidData when the encoded length exceeds max_len or the payload is not valid UTF-8.

§Stream position

If the decoded length exceeds max_len, the length prefix has been consumed, but the payload remains unread. If UTF-8 validation fails, the prefix and complete payload have been consumed. These operations do not roll back; recover only at an outer framing boundary or a trusted seek checkpoint. See StringReadExt for the shared length-prefixed read contract.

Trait Implementations§

Source§

impl<R, O> Input for BinaryReader<R, O>
where R: ByteInput,

Source§

type Item = u8

The byte type yielded by this reader.

Source§

fn is_buffered(&self) -> bool

Reports whether the wrapped input is buffered.

§Returns

Returns the wrapped input’s buffering state.

Source§

unsafe fn read_unchecked( &mut self, output: &mut [u8], index: usize, count: usize, ) -> Result<usize>

Reads up to count bytes into an indexed output range.

§Parameters
  • output: Destination slice.
  • index: First destination index.
  • count: Maximum number of bytes to read.
§Returns

Returns the number of bytes read.

§Errors

Returns an error reported by the wrapped input.

§Safety

index..index + count must be a valid range within output.

Source§

fn into_std_read(self) -> StdRead<Self> ⓘ
where Self: Sized + ByteInput,

Converts this byte input into a standard library reader. Read more
Source§

fn read(&mut self, output: &mut [Self::Item]) -> Result<usize, Error>

Reads items into the full output slice. Read more
Source§

unsafe fn read_fully_unchecked( &mut self, output: &mut [Self::Item], index: usize, count: usize, ) -> Result<usize, Error>

Reads items into an indexed output range until it is full or EOF is reached. Read more
Source§

fn read_fully(&mut self, output: &mut [Self::Item]) -> Result<usize, Error>

Reads items into the full output slice until it is full or EOF is reached. Read more
Source§

fn read_exactly(&mut self, output: &mut [Self::Item]) -> Result<(), Error>

Reads items until the full output slice is filled. Read more
Source§

fn read_vectored( &mut self, buffers: &mut [&mut [Self::Item]], ) -> Result<usize, Error>

Reads items into multiple buffers in list order. Read more
Source§

impl<R, O> Seekable for BinaryReader<R, O>

Source§

type Unit = u8

The unit used to measure positions in the wrapped byte stream: bytes.

Source§

fn seek_to(&mut self, position: SeekFrom) -> Result<u64>

Seeks the wrapped input.

§Parameters
  • position: Target seek position.
§Returns

Returns the new stream position.

§Errors

Returns the seek error reported by the wrapped reader.

Auto Trait Implementations§

§

impl<R, O> Forget for BinaryReader<R, O>

§

impl<R, O> Freeze for BinaryReader<R, O>
where R: Freeze, PhantomData<fn() -> O>: Freeze,

§

impl<R, O> Move for BinaryReader<R, O>

§

impl<R, O> RefUnwindSafe for BinaryReader<R, O>

§

impl<R, O> Send for BinaryReader<R, O>
where R: Send, PhantomData<fn() -> O>: Send,

§

impl<R, O> Sync for BinaryReader<R, O>
where R: Sync, PhantomData<fn() -> O>: Sync,

§

impl<R, O> Unpin for BinaryReader<R, O>
where R: Unpin, PhantomData<fn() -> O>: Unpin,

§

impl<R, O> UnsafeUnpin for BinaryReader<R, O>

§

impl<R, O> UnwindSafe for BinaryReader<R, O>
where R: UnwindSafe, PhantomData<fn() -> O>: 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<R> BinaryReadExt for R
where R: ByteInput + ?Sized,

Source§

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

Reads an unsigned 8-bit integer. Read more
Source§

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

Reads a signed 8-bit integer. Read more
Source§

fn read_u16(&mut self, byte_order: ByteOrder) -> Result<u16>

Reads an unsigned 16-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian unsigned 16-bit integer. Read more
Source§

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

Reads a little-endian unsigned 16-bit integer. Read more
Source§

fn read_u32(&mut self, byte_order: ByteOrder) -> Result<u32>

Reads an unsigned 32-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian unsigned 32-bit integer. Read more
Source§

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

Reads a little-endian unsigned 32-bit integer. Read more
Source§

fn read_u64(&mut self, byte_order: ByteOrder) -> Result<u64>

Reads an unsigned 64-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian unsigned 64-bit integer. Read more
Source§

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

Reads a little-endian unsigned 64-bit integer. Read more
Source§

fn read_u128(&mut self, byte_order: ByteOrder) -> Result<u128>

Reads an unsigned 128-bit integer using a runtime byte order. Read more
Source§

fn read_u128_be(&mut self) -> Result<u128>

Reads a big-endian unsigned 128-bit integer. Read more
Source§

fn read_u128_le(&mut self) -> Result<u128>

Reads a little-endian unsigned 128-bit integer. Read more
Source§

fn read_i16(&mut self, byte_order: ByteOrder) -> Result<i16>

Reads a signed 16-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian signed 16-bit integer. Read more
Source§

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

Reads a little-endian signed 16-bit integer. Read more
Source§

fn read_i32(&mut self, byte_order: ByteOrder) -> Result<i32>

Reads a signed 32-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian signed 32-bit integer. Read more
Source§

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

Reads a little-endian signed 32-bit integer. Read more
Source§

fn read_i64(&mut self, byte_order: ByteOrder) -> Result<i64>

Reads a signed 64-bit integer using a runtime byte order. Read more
Source§

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

Reads a big-endian signed 64-bit integer. Read more
Source§

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

Reads a little-endian signed 64-bit integer. Read more
Source§

fn read_i128(&mut self, byte_order: ByteOrder) -> Result<i128>

Reads a signed 128-bit integer using a runtime byte order. Read more
Source§

fn read_i128_be(&mut self) -> Result<i128>

Reads a big-endian signed 128-bit integer. Read more
Source§

fn read_i128_le(&mut self) -> Result<i128>

Reads a little-endian signed 128-bit integer. Read more
Source§

fn read_f32(&mut self, byte_order: ByteOrder) -> Result<f32>

Reads a 32-bit float using a runtime byte order. Read more
Source§

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

Reads a big-endian 32-bit float. Read more
Source§

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

Reads a little-endian 32-bit float. Read more
Source§

fn read_f64(&mut self, byte_order: ByteOrder) -> Result<f64>

Reads a 64-bit float using a runtime byte order. Read more
Source§

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

Reads a big-endian 64-bit float. Read more
Source§

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

Reads a little-endian 64-bit float. 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> ByteInput for T
where T: Input<Item = u8> + ?Sized,

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<R> Leb128ReadExt for R
where R: ByteInput + ?Sized,

Source§

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

Reads a non-strict unsigned LEB128 u8. Read more
Source§

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

Reads a strict unsigned LEB128 u8. Read more
Source§

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

Reads a non-strict unsigned LEB128 u16. Read more
Source§

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

Reads a strict unsigned LEB128 u16. Read more
Source§

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

Reads a non-strict unsigned LEB128 u32. Read more
Source§

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

Reads a strict unsigned LEB128 u32. Read more
Source§

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

Reads a non-strict unsigned LEB128 u64. Read more
Source§

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

Reads a strict unsigned LEB128 u64. Read more
Source§

fn read_uleb_u128_non_strict(&mut self) -> Result<u128>

Reads a non-strict unsigned LEB128 u128. Read more
Source§

fn read_uleb_u128_strict(&mut self) -> Result<u128>

Reads a strict unsigned LEB128 u128. Read more
Source§

fn read_uleb_usize_non_strict(&mut self) -> Result<usize>

Reads a non-strict unsigned LEB128 usize. Read more
Source§

fn read_uleb_usize_strict(&mut self) -> Result<usize>

Reads a strict unsigned LEB128 usize. Read more
Source§

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

Reads a non-strict signed LEB128 i8. Read more
Source§

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

Reads a strict signed LEB128 i8. Read more
Source§

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

Reads a non-strict signed LEB128 i16. Read more
Source§

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

Reads a strict signed LEB128 i16. Read more
Source§

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

Reads a non-strict signed LEB128 i32. Read more
Source§

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

Reads a strict signed LEB128 i32. Read more
Source§

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

Reads a non-strict signed LEB128 i64. Read more
Source§

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

Reads a strict signed LEB128 i64. Read more
Source§

fn read_sleb_i128_non_strict(&mut self) -> Result<i128>

Reads a non-strict signed LEB128 i128. Read more
Source§

fn read_sleb_i128_strict(&mut self) -> Result<i128>

Reads a strict signed LEB128 i128. Read more
Source§

fn read_sleb_isize_non_strict(&mut self) -> Result<isize>

Reads a non-strict signed LEB128 isize. Read more
Source§

fn read_sleb_isize_strict(&mut self) -> Result<isize>

Reads a strict signed LEB128 isize. Read more
Source§

impl<T> SeekableByteInput for T
where T: SeekableInput<Item = u8, Unit = u8> + ?Sized,

Source§

impl<T> SeekableInput for T
where T: Input + Seekable<Unit = <T as Input>::Item> + ?Sized,

Source§

impl<T> StringReadExt for T
where T: ByteInput + ?Sized,

Source§

fn read_utf8_payload_into( &mut self, bytes: &mut Vec<u8>, len: usize, max_len: usize, ) -> Result<(), Error>

Reads a validated UTF-8 payload into the caller’s reusable byte buffer.

The buffer contents and error behavior follow the contract documented on StringReadExt::read_utf8_payload_into.

§Parameters
  • bytes: Reusable destination buffer for the received payload.
  • len: UTF-8 payload length in bytes.
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_utf8_payload( &mut self, len: usize, max_len: usize, ) -> Result<String, Error>

Reads and validates a UTF-8 payload whose byte length is already known.

Length limits and input-consumption behavior follow the contract documented on StringReadExt::read_utf8_payload.

§Parameters
  • len: UTF-8 payload length in bytes.
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_utf8_string_uleb_usize( &mut self, max_len: usize, ) -> Result<String, Error>

Decodes a non-strict usize ULEB128 length and reads that UTF-8 payload.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_utf8_string_uleb_usize_strict( &mut self, max_len: usize, ) -> Result<String, Error>

Decodes a canonical usize ULEB128 length and reads that UTF-8 payload.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_utf8_string_uleb_u64(&mut self, max_len: usize) -> Result<String, Error>

Decodes a non-strict u64 ULEB128 length and reads that UTF-8 payload.

Returns an invalid-data error if the length cannot fit in usize.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_utf8_string_uleb_u64_strict( &mut self, max_len: usize, ) -> Result<String, Error>

Decodes a canonical u64 ULEB128 length and reads that UTF-8 payload.

Returns an invalid-data error for a malformed prefix or a length that cannot fit in usize.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u16_len( &mut self, byte_order: ByteOrder, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a u16 length in the selected byte order.

§Parameters
  • byte_order: Byte order used by the length prefix.
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u16_len_be( &mut self, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a big-endian u16 length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u16_len_le( &mut self, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a little-endian u16 length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u32_len( &mut self, byte_order: ByteOrder, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a u32 length in the selected byte order.

§Parameters
  • byte_order: Byte order used by the length prefix.
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u32_len_be( &mut self, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a big-endian u32 length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

fn read_string_with_u32_len_le( &mut self, max_len: usize, ) -> Result<String, Error>

Reads a UTF-8 payload preceded by a little-endian u32 length.

§Parameters
  • max_len: Maximum accepted UTF-8 payload length in bytes.
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<R> ZigZagReadExt for R
where R: ByteInput + ?Sized,

Source§

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

Reads a non-strict ZigZag i8. Read more
Source§

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

Reads a strict ZigZag i8. Read more
Source§

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

Reads a non-strict ZigZag i16. Read more
Source§

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

Reads a strict ZigZag i16. Read more
Source§

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

Reads a non-strict ZigZag i32. Read more
Source§

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

Reads a strict ZigZag i32. Read more
Source§

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

Reads a non-strict ZigZag i64. Read more
Source§

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

Reads a strict ZigZag i64. Read more
Source§

fn read_zig_zag_i128_non_strict(&mut self) -> Result<i128>

Reads a non-strict ZigZag i128. Read more
Source§

fn read_zig_zag_i128_strict(&mut self) -> Result<i128>

Reads a strict ZigZag i128. Read more
Source§

fn read_zig_zag_isize_non_strict(&mut self) -> Result<isize>

Reads a non-strict ZigZag isize. Read more
Source§

fn read_zig_zag_isize_strict(&mut self) -> Result<isize>

Reads a strict ZigZag isize. Read more