Skip to main content

BinaryReadExt

Trait BinaryReadExt 

Source
pub trait BinaryReadExt: Read {
Show 32 methods // Required methods fn read_u8(&mut self) -> Result<u8>; fn read_i8(&mut self) -> Result<i8>; fn read_u16_be(&mut self) -> Result<u16>; fn read_u16_le(&mut self) -> Result<u16>; fn read_i16_be(&mut self) -> Result<i16>; fn read_i16_le(&mut self) -> Result<i16>; fn read_u32_be(&mut self) -> Result<u32>; fn read_u32_le(&mut self) -> Result<u32>; fn read_i32_be(&mut self) -> Result<i32>; fn read_i32_le(&mut self) -> Result<i32>; fn read_u64_be(&mut self) -> Result<u64>; fn read_u64_le(&mut self) -> Result<u64>; fn read_i64_be(&mut self) -> Result<i64>; fn read_i64_le(&mut self) -> Result<i64>; fn read_u128_be(&mut self) -> Result<u128>; fn read_u128_le(&mut self) -> Result<u128>; fn read_i128_be(&mut self) -> Result<i128>; fn read_i128_le(&mut self) -> Result<i128>; fn read_f32_be(&mut self) -> Result<f32>; fn read_f32_le(&mut self) -> Result<f32>; fn read_f64_be(&mut self) -> Result<f64>; fn read_f64_le(&mut self) -> Result<f64>; // Provided methods fn read_u16(&mut self, order: ByteOrder) -> Result<u16> { ... } fn read_i16(&mut self, order: ByteOrder) -> Result<i16> { ... } fn read_u32(&mut self, order: ByteOrder) -> Result<u32> { ... } fn read_i32(&mut self, order: ByteOrder) -> Result<i32> { ... } fn read_u64(&mut self, order: ByteOrder) -> Result<u64> { ... } fn read_i64(&mut self, order: ByteOrder) -> Result<i64> { ... } fn read_u128(&mut self, order: ByteOrder) -> Result<u128> { ... } fn read_i128(&mut self, order: ByteOrder) -> Result<i128> { ... } fn read_f32(&mut self, order: ByteOrder) -> Result<f32> { ... } fn read_f64(&mut self, order: ByteOrder) -> Result<f64> { ... }
}
Expand description

Extension methods for reading binary scalar values from Read streams.

Multi-byte values can be read either with explicit byte-order suffixes or with a runtime ByteOrder argument. All methods read exactly the required number of bytes and therefore return std::io::ErrorKind::UnexpectedEof when the stream ends early.

Required Methods§

Source

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

Reads one unsigned byte.

§Returns

The byte value.

§Errors

Returns an I/O error from the underlying reader, including UnexpectedEof when no byte is available.

Source

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

Reads one signed byte.

§Returns

The byte interpreted as i8.

§Errors

Returns an I/O error from the underlying reader, including UnexpectedEof when no byte is available.

Source

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

Reads a big-endian u16.

§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads a little-endian u16.

§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads a big-endian i16.

§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads a little-endian i16.

§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads a big-endian u32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a little-endian u32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a big-endian i32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a little-endian i32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a big-endian u64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a little-endian u64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a big-endian i64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a little-endian i64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a big-endian u128.

§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads a little-endian u128.

§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads a big-endian i128.

§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads a little-endian i128.

§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads a big-endian IEEE-754 f32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a little-endian IEEE-754 f32.

§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a big-endian IEEE-754 f64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a little-endian IEEE-754 f64.

§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Provided Methods§

Source

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

Reads a u16 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads an i16 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when two bytes cannot be read.

Source

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

Reads a u32 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads an i32 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads a u64 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads an i64 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Source

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

Reads a u128 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads an i128 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when sixteen bytes cannot be read.

Source

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

Reads an IEEE-754 f32 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when four bytes cannot be read.

Source

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

Reads an IEEE-754 f64 using order.

§Parameters
  • order: Byte order used to decode the value.
§Returns

The decoded value.

§Errors

Returns an I/O error when eight bytes cannot be read.

Implementors§

Source§

impl<T> BinaryReadExt for T
where T: Read + ?Sized,