TableRef

Struct TableRef 

Source
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>

Source

pub fn at(buf: &'a [u8], pos: usize) -> Result<Self, Error>

Table with a [u16 fixed_len] header at pos.

Source

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.

Source

pub fn buf(&self) -> &'a [u8] ⓘ

Source

pub fn fixed_len(&self) -> u16

Source

pub fn fixed_start(&self) -> usize

Absolute position of the fixed part’s first byte.

Source

pub fn fixed_byte(&self, i: u16) -> u8

One byte of the fixed part; outside fixed_len ⇒ 0.

Source

pub fn bit(&self, b: Bit) -> bool

Bit value; a bit byte outside fixed_len reads as false (absent).

Source

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.

Source

pub fn scalar<T: Le>(&self, off: u16, presence: Bit) -> Result<Option<T>, Error>

Scalar with presence bit, following the field read rule.

Source

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

pub fn raw<T: Le>(&self, off: u16) -> T

Slot value ignoring presence, for required fields already validated by the generated read(). Slot not fully inside fixed_len ⇒ T::default().

Source

pub fn bool(&self, presence: Bit) -> Option<bool>

Bool stored as presence bit + value bit (shift + 1).

Source§

impl<'a> TableRef<'a>

Source

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.

Source

pub fn bytes(&self, off: u16) -> Result<Option<&'a [u8]>, Error>

Source

pub fn str(&self, off: u16) -> Result<Option<&'a str>, Error>

Source

pub fn table(&self, off: u16) -> Result<Option<TableRef<'a>>, Error>

Source

pub fn union(&self, off: u16) -> Result<Option<(u16, TableRef<'a>)>, Error>

Union slot [u16 tag][i32 ptr]; tag 0 ⇒ None.

Source

pub fn scalars<T: Le>( &self, off: u16, ) -> Result<Option<ScalarList<'a, T>>, Error>

Source

pub fn tables(&self, off: u16) -> Result<Option<TableList<'a>>, Error>

Source

pub fn strs(&self, off: u16) -> Result<Option<StrList<'a>>, Error>

Trait Implementations§

Source§

impl<'a> Clone for TableRef<'a>

Source§

fn clone(&self) -> TableRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for TableRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.