pub struct Cursor<'a> { /* private fields */ }Expand description
A cursor over a byte slice for sequential reading with endian-aware helpers.
All HDF5 file parsing goes through this type. It wraps a &[u8] and tracks
the current position. Methods advance the position on success.
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn set_position(&mut self, pos: u64)
pub fn set_position(&mut self, pos: u64)
Set the position.
Sourcepub fn slice_from(&self, offset: u64) -> Result<&'a [u8]>
pub fn slice_from(&self, offset: u64) -> Result<&'a [u8]>
Get a slice starting from an absolute offset.
Sourcepub fn at_offset(&self, offset: u64) -> Result<Cursor<'a>>
pub fn at_offset(&self, offset: u64) -> Result<Cursor<'a>>
Create a new cursor at a given absolute offset.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8]>
Read exactly n bytes and advance.
Sourcepub fn peek_bytes(&self, n: usize) -> Result<&'a [u8]>
pub fn peek_bytes(&self, n: usize) -> Result<&'a [u8]>
Peek at the next n bytes without advancing.
pub fn read_u8(&mut self) -> Result<u8>
pub fn read_i8(&mut self) -> Result<i8>
pub fn read_u16_le(&mut self) -> Result<u16>
pub fn read_u32_le(&mut self) -> Result<u32>
pub fn read_u64_le(&mut self) -> Result<u64>
pub fn read_i16_le(&mut self) -> Result<i16>
pub fn read_i32_le(&mut self) -> Result<i32>
pub fn read_i64_le(&mut self) -> Result<i64>
pub fn read_f32_le(&mut self) -> Result<f32>
pub fn read_f64_le(&mut self) -> Result<f64>
pub fn read_u16_be(&mut self) -> Result<u16>
pub fn read_u32_be(&mut self) -> Result<u32>
pub fn read_u64_be(&mut self) -> Result<u64>
pub fn read_u16(&mut self, order: ByteOrder) -> Result<u16>
pub fn read_u32(&mut self, order: ByteOrder) -> Result<u32>
pub fn read_u64(&mut self, order: ByteOrder) -> Result<u64>
Sourcepub fn read_offset(&mut self, size: u8) -> Result<u64>
pub fn read_offset(&mut self, size: u8) -> Result<u64>
Read an offset (address) of size bytes (little-endian).
HDF5 uses 2/4/8-byte offsets depending on superblock configuration.
Sourcepub fn read_length(&mut self, size: u8) -> Result<u64>
pub fn read_length(&mut self, size: u8) -> Result<u64>
Read a length of size bytes (little-endian).
Sourcepub fn read_uvar(&mut self, size: usize) -> Result<u64>
pub fn read_uvar(&mut self, size: usize) -> Result<u64>
Read a variable-size unsigned integer of 1..=8 bytes (little-endian).
Sourcepub fn is_undefined_offset(val: u64, offset_size: u8) -> bool
pub fn is_undefined_offset(val: u64, offset_size: u8) -> bool
Check if an offset value represents the “undefined” address.
Sourcepub fn read_null_terminated_string(&mut self) -> Result<String>
pub fn read_null_terminated_string(&mut self) -> Result<String>
Read a null-terminated UTF-8 string.
Sourcepub fn read_fixed_string(&mut self, len: usize) -> Result<String>
pub fn read_fixed_string(&mut self, len: usize) -> Result<String>
Read a fixed-length string, trimming null padding.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Send for Cursor<'a>
impl<'a> Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnsafeUnpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more