Trait Peek

Source
pub trait Peek {
Show 48 methods // Required methods fn peek(&mut self, buf: &mut [u8]) -> Result<usize>; fn peek_exact(&mut self, buf: &mut [u8]) -> Result<()>; fn peek_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>; fn peek_exact_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>; fn peek_cstring(&mut self) -> Result<CString>; fn peek_cstring_at(&mut self, offset: u64) -> Result<CString>; fn read_struct<T: StructUnpack>( &mut self, big: bool, encoding: Encoding, ) -> Result<T>; // Provided methods fn peek_at_vec(&mut self, offset: u64, len: usize) -> Result<Vec<u8>> { ... } fn peek_exact_at_vec(&mut self, offset: u64, len: usize) -> Result<Vec<u8>> { ... } fn peek_u8(&mut self) -> Result<u8> { ... } fn peek_u16(&mut self) -> Result<u16> { ... } fn peek_u16_be(&mut self) -> Result<u16> { ... } fn peek_u32(&mut self) -> Result<u32> { ... } fn peek_u32_be(&mut self) -> Result<u32> { ... } fn peek_u64(&mut self) -> Result<u64> { ... } fn peek_u64_be(&mut self) -> Result<u64> { ... } fn peek_u128(&mut self) -> Result<u128> { ... } fn peek_u128_be(&mut self) -> Result<u128> { ... } fn peek_i8(&mut self) -> Result<i8> { ... } fn peek_i16(&mut self) -> Result<i16> { ... } fn peek_i16_be(&mut self) -> Result<i16> { ... } fn peek_i32(&mut self) -> Result<i32> { ... } fn peek_i32_be(&mut self) -> Result<i32> { ... } fn peek_i64(&mut self) -> Result<i64> { ... } fn peek_i64_be(&mut self) -> Result<i64> { ... } fn peek_i128(&mut self) -> Result<i128> { ... } fn peek_i128_be(&mut self) -> Result<i128> { ... } fn peek_u8_at(&mut self, offset: u64) -> Result<u8> { ... } fn peek_u16_at(&mut self, offset: u64) -> Result<u16> { ... } fn peek_u16_be_at(&mut self, offset: u64) -> Result<u16> { ... } fn peek_u32_at(&mut self, offset: u64) -> Result<u32> { ... } fn peek_u32_be_at(&mut self, offset: u64) -> Result<u32> { ... } fn peek_u64_at(&mut self, offset: u64) -> Result<u64> { ... } fn peek_u64_be_at(&mut self, offset: u64) -> Result<u64> { ... } fn peek_u128_at(&mut self, offset: u64) -> Result<u128> { ... } fn peek_u128_be_at(&mut self, offset: u64) -> Result<u128> { ... } fn peek_i8_at(&mut self, offset: u64) -> Result<i8> { ... } fn peek_i16_at(&mut self, offset: u64) -> Result<i16> { ... } fn peek_i16_be_at(&mut self, offset: u64) -> Result<i16> { ... } fn peek_i32_at(&mut self, offset: u64) -> Result<i32> { ... } fn peek_i32_be_at(&mut self, offset: u64) -> Result<i32> { ... } fn peek_i64_at(&mut self, offset: u64) -> Result<i64> { ... } fn peek_i64_be_at(&mut self, offset: u64) -> Result<i64> { ... } fn peek_i128_at(&mut self, offset: u64) -> Result<i128> { ... } fn peek_i128_be_at(&mut self, offset: u64) -> Result<i128> { ... } fn read_struct_vec<T: StructUnpack>( &mut self, count: usize, big: bool, encoding: Encoding, ) -> Result<Vec<T>> { ... } fn peek_and_equal(&mut self, data: &[u8]) -> Result<()> { ... } fn peek_and_equal_at(&mut self, offset: u64, data: &[u8]) -> Result<()> { ... }
}
Expand description

A trait to help to peek data from a reader.

Required Methods§

Source

fn peek(&mut self, buf: &mut [u8]) -> Result<usize>

Peeks data from the reader into the provided buffer. Returns the number of bytes read.

Source

fn peek_exact(&mut self, buf: &mut [u8]) -> Result<()>

Peeks data from the reader into the provided buffer. Returns an error if the buffer is not filled completely.

Source

fn peek_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Peeks data from the reader at a specific offset into the provided buffer. Returns the number of bytes read.

Source

fn peek_exact_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>

Peeks data from the reader at a specific offset into the provided buffer. Returns an error if the buffer is not filled completely.

Source

fn peek_cstring(&mut self) -> Result<CString>

Peeks a C-style string (null-terminated) from the reader.

Source

fn peek_cstring_at(&mut self, offset: u64) -> Result<CString>

Peeks a C-style string (null-terminated) from the reader at a specific offset.

Source

fn read_struct<T: StructUnpack>( &mut self, big: bool, encoding: Encoding, ) -> Result<T>

Reads a struct from the reader. The struct must implement the StructUnpack trait.

  • big indicates whether the struct is in big-endian format.
  • encoding specifies the encoding to use for string fields in the struct. Returns the unpacked struct.

Provided Methods§

Source

fn peek_at_vec(&mut self, offset: u64, len: usize) -> Result<Vec<u8>>

Peeks data from the reader at a specific offset into a vector. Returns the vector containing the data read.

Source

fn peek_exact_at_vec(&mut self, offset: u64, len: usize) -> Result<Vec<u8>>

Peeks data from the reader at a specific offset into a vector. Returns an error if the buffer is not filled completely.

Source

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

Peeks a u8 from the reader.

Source

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

Peeks a u16 from the reader in little-endian order.

Source

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

Peeks a u16 from the reader in big-endian order.

Source

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

Peeks a u32 from the reader in little-endian order.

Source

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

Peeks a u32 from the reader in big-endian order.

Source

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

Peeks a u64 from the reader in little-endian order.

Source

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

Peeks a u64 from the reader in big-endian order.

Source

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

Peeks a u128 from the reader in little-endian order.

Source

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

Peeks a u128 from the reader in big-endian order.

Source

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

Peeks an i8 from the reader.

Source

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

Peeks an i16 from the reader in little-endian order.

Source

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

Peeks an i16 from the reader in big-endian order.

Source

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

Peeks an i32 from the reader in little-endian order.

Source

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

Peeks an i32 from the reader in big-endian order.

Source

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

Peeks an i64 from the reader in little-endian order.

Source

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

Peeks an i64 from the reader in big-endian order.

Source

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

Peeks an i128 from the reader in little-endian order.

Source

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

Peeks an i128 from the reader in big-endian order.

Source

fn peek_u8_at(&mut self, offset: u64) -> Result<u8>

Peeks a u8 at a specific offset from the reader.

Source

fn peek_u16_at(&mut self, offset: u64) -> Result<u16>

Peeks a u16 at a specific offset from the reader in little-endian order.

Source

fn peek_u16_be_at(&mut self, offset: u64) -> Result<u16>

Peeks a u16 at a specific offset from the reader in big-endian order.

Source

fn peek_u32_at(&mut self, offset: u64) -> Result<u32>

Peeks a u32 at a specific offset from the reader in little-endian order.

Source

fn peek_u32_be_at(&mut self, offset: u64) -> Result<u32>

Peeks a u32 at a specific offset from the reader in big-endian order.

Source

fn peek_u64_at(&mut self, offset: u64) -> Result<u64>

Peeks a u64 at a specific offset from the reader in little-endian order.

Source

fn peek_u64_be_at(&mut self, offset: u64) -> Result<u64>

Peeks a u64 at a specific offset from the reader in big-endian order.

Source

fn peek_u128_at(&mut self, offset: u64) -> Result<u128>

Peeks a u128 at a specific offset from the reader in little-endian order.

Source

fn peek_u128_be_at(&mut self, offset: u64) -> Result<u128>

Peeks a u128 at a specific offset from the reader in big-endian order.

Source

fn peek_i8_at(&mut self, offset: u64) -> Result<i8>

Peeks an i8 at a specific offset from the reader.

Source

fn peek_i16_at(&mut self, offset: u64) -> Result<i16>

Peeks an i16 at a specific offset from the reader in little-endian order.

Source

fn peek_i16_be_at(&mut self, offset: u64) -> Result<i16>

Peeks an i16 at a specific offset from the reader in big-endian order.

Source

fn peek_i32_at(&mut self, offset: u64) -> Result<i32>

Peeks an i32 at a specific offset from the reader in little-endian order.

Source

fn peek_i32_be_at(&mut self, offset: u64) -> Result<i32>

Peeks an i32 at a specific offset from the reader in big-endian order.

Source

fn peek_i64_at(&mut self, offset: u64) -> Result<i64>

Peeks an i64 at a specific offset from the reader in little-endian order.

Source

fn peek_i64_be_at(&mut self, offset: u64) -> Result<i64>

Peeks an i64 at a specific offset from the reader in big-endian order.

Source

fn peek_i128_at(&mut self, offset: u64) -> Result<i128>

Peeks an i128 at a specific offset from the reader in little-endian order.

Source

fn peek_i128_be_at(&mut self, offset: u64) -> Result<i128>

Peeks an i128 at a specific offset from the reader in big-endian order.

Source

fn read_struct_vec<T: StructUnpack>( &mut self, count: usize, big: bool, encoding: Encoding, ) -> Result<Vec<T>>

Reads a vector of structs from the reader. The structs must implement the StructUnpack trait.

  • count is the number of structs to read.
  • big indicates whether the structs are in big-endian format.
  • encoding specifies the encoding to use for string fields in the structs. Returns a vector of unpacked structs.
Source

fn peek_and_equal(&mut self, data: &[u8]) -> Result<()>

Peeks data and checks if it matches the provided data.

Source

fn peek_and_equal_at(&mut self, offset: u64, data: &[u8]) -> Result<()>

Peeks data at a specific offset and checks if it matches the provided data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Read + Seek> Peek for T