pub struct TableRef<'a> { /* private fields */ }Expand description
A view over one table’s fixed part. Never panics on malformed input.
Implementations§
Source§impl<'a> TableRef<'a>
impl<'a> TableRef<'a>
Sourcepub fn at(buf: &'a [u8], pos: usize) -> Result<Self, Error>
pub fn at(buf: &'a [u8], pos: usize) -> Result<Self, Error>
Table with a [u16 fixed_len] header at pos.
Sourcepub fn inline(
buf: &'a [u8],
fixed_start: usize,
fixed_len: u16,
) -> Result<Self, Error>
pub fn inline( buf: &'a [u8], fixed_start: usize, fixed_len: u16, ) -> Result<Self, Error>
Header-less table (list element) whose fixed part starts at fixed_start.
pub fn buf(&self) -> &'a [u8] ⓘ
pub fn fixed_len(&self) -> u16
Sourcepub fn fixed_start(&self) -> usize
pub fn fixed_start(&self) -> usize
Absolute position of the fixed part’s first byte.
Sourcepub fn fixed_byte(&self, i: u16) -> u8
pub fn fixed_byte(&self, i: u16) -> u8
One byte of the fixed part; outside fixed_len ⇒ 0.
Sourcepub fn bit(&self, b: Bit) -> bool
pub fn bit(&self, b: Bit) -> bool
Bit value; a bit byte outside fixed_len reads as false (absent).
Sourcepub fn slot_state(&self, off: u16, size: u16) -> Result<bool, Error>
pub fn slot_state(&self, off: u16, size: u16) -> Result<bool, Error>
Ok(true) if the slot is fully inside fixed_len, Ok(false) if fully
outside, Err(Truncated) if partially covered.
Sourcepub fn scalar<T: Le>(&self, off: u16, presence: Bit) -> Result<Option<T>, Error>
pub fn scalar<T: Le>(&self, off: u16, presence: Bit) -> Result<Option<T>, Error>
Scalar with presence bit, following the field read rule.
Sourcepub fn scalar_or<T: Le>(&self, off: u16, presence: Bit, default: T) -> T
pub fn scalar_or<T: Le>(&self, off: u16, presence: Bit, default: T) -> T
Scalar for an already-validated required field; any anomaly yields default.
Source§impl<'a> TableRef<'a>
impl<'a> TableRef<'a>
Sourcepub fn ptr(&self, off: u16) -> Result<Option<usize>, Error>
pub fn ptr(&self, off: u16) -> Result<Option<usize>, Error>
Absolute target of the pointer at slot off. Slot outside fixed_len or 0 ⇒ None.
pub fn bytes(&self, off: u16) -> Result<Option<&'a [u8]>, Error>
pub fn str(&self, off: u16) -> Result<Option<&'a str>, Error>
pub fn table(&self, off: u16) -> Result<Option<TableRef<'a>>, Error>
Sourcepub fn union(&self, off: u16) -> Result<Option<(u16, TableRef<'a>)>, Error>
pub fn union(&self, off: u16) -> Result<Option<(u16, TableRef<'a>)>, Error>
Union slot [u16 tag][i32 ptr]; tag 0 ⇒ None.
pub fn scalars<T: Le>( &self, off: u16, ) -> Result<Option<ScalarList<'a, T>>, Error>
pub fn tables(&self, off: u16) -> Result<Option<TableList<'a>>, Error>
pub fn strs(&self, off: u16) -> Result<Option<StrList<'a>>, Error>
Trait Implementations§
impl<'a> Copy for TableRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for TableRef<'a>
impl<'a> RefUnwindSafe for TableRef<'a>
impl<'a> Send for TableRef<'a>
impl<'a> Sync for TableRef<'a>
impl<'a> Unpin for TableRef<'a>
impl<'a> UnwindSafe for TableRef<'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
Mutably borrows from an owned value. Read more