Skip to main content

Leb128ReadExt

Trait Leb128ReadExt 

Source
pub trait Leb128ReadExt: ByteInput {
Show 24 methods // Provided methods fn read_uleb_u8_non_strict(&mut self) -> Result<u8> { ... } fn read_uleb_u8_strict(&mut self) -> Result<u8> { ... } fn read_uleb_u16_non_strict(&mut self) -> Result<u16> { ... } fn read_uleb_u16_strict(&mut self) -> Result<u16> { ... } fn read_uleb_u32_non_strict(&mut self) -> Result<u32> { ... } fn read_uleb_u32_strict(&mut self) -> Result<u32> { ... } fn read_uleb_u64_non_strict(&mut self) -> Result<u64> { ... } fn read_uleb_u64_strict(&mut self) -> Result<u64> { ... } fn read_uleb_u128_non_strict(&mut self) -> Result<u128> { ... } fn read_uleb_u128_strict(&mut self) -> Result<u128> { ... } fn read_uleb_usize_non_strict(&mut self) -> Result<usize> { ... } fn read_uleb_usize_strict(&mut self) -> Result<usize> { ... } fn read_sleb_i8_non_strict(&mut self) -> Result<i8> { ... } fn read_sleb_i8_strict(&mut self) -> Result<i8> { ... } fn read_sleb_i16_non_strict(&mut self) -> Result<i16> { ... } fn read_sleb_i16_strict(&mut self) -> Result<i16> { ... } fn read_sleb_i32_non_strict(&mut self) -> Result<i32> { ... } fn read_sleb_i32_strict(&mut self) -> Result<i32> { ... } fn read_sleb_i64_non_strict(&mut self) -> Result<i64> { ... } fn read_sleb_i64_strict(&mut self) -> Result<i64> { ... } fn read_sleb_i128_non_strict(&mut self) -> Result<i128> { ... } fn read_sleb_i128_strict(&mut self) -> Result<i128> { ... } fn read_sleb_isize_non_strict(&mut self) -> Result<isize> { ... } fn read_sleb_isize_strict(&mut self) -> Result<isize> { ... }
}
Expand description

Extension methods for reading LEB128 integers from byte streams.

§Target-width integers

usize and isize methods use the current Rust target’s pointer width. Prefer fixed-width integer methods such as Self::read_uleb_u64_non_strict or Self::read_sleb_i64_non_strict for persistent files and cross-platform protocols. Non-strict methods use the _non_strict suffix; canonical-only methods use the corresponding _strict suffix. A failed synchronous read may have consumed part of the current value. Do not blindly retry the same operation; resume only from a framing boundary or a trusted seek checkpoint.

§Examples

A non-strict read accepts an overlong encoding that the strict method rejects:

use std::io::Cursor;
use std::io::ErrorKind;
use qubit_io_binary::Leb128ReadExt;

let mut permissive = Cursor::new([0x80, 0x00]);
assert_eq!(permissive.read_uleb_u64_non_strict()?, 0);
let mut strict = Cursor::new([0x80, 0x00]);
assert_eq!(strict.read_uleb_u64_strict().unwrap_err().kind(), ErrorKind::InvalidData);

Provided Methods§

Source

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

Reads a non-strict unsigned LEB128 u8.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 u8.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict unsigned LEB128 u16.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 u16.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict unsigned LEB128 u32.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 u32.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict unsigned LEB128 u64.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 u64.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict unsigned LEB128 u128.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 u128.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict unsigned LEB128 usize.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict unsigned LEB128 usize.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 i8.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 i8.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 i16.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 i16.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 i32.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 i32.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 i64.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 i64.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 i128.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 i128.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a non-strict signed LEB128 isize.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Source

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

Reads a strict signed LEB128 isize.

§Returns

Returns the decoded integer.

§Errors

Returns an input error or an invalid-data error when the payload is malformed or violates the selected canonicality policy.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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