Struct Verifier

Source
pub struct Verifier<'opts, 'buf> { /* private fields */ }
Expand description

Carries the verification state. Should not be reused between tables.

Implementations§

Source§

impl<'opts, 'buf> Verifier<'opts, 'buf>

Source

pub fn new(opts: &'opts VerifierOptions, buffer: &'buf [u8]) -> Self

Source

pub fn reset(&mut self)

Resets verifier internal state.

Source

pub fn is_aligned<T>(&self, pos: usize) -> Result<(), InvalidFlatbuffer>

Checks pos is aligned to T’s alignment. This does not mean buffer[pos] is aligned w.r.t memory since buffer: &[u8] has alignment 1.

§WARNING

This does not work for flatbuffers-structs as they have alignment 1 according to core::mem::align_of but are meant to have higher alignment within a Flatbuffer w.r.t. buffer[0]. TODO(caspern).

Note this does not impact soundness as this crate does not assume alignment of structs

Source

pub fn range_in_buffer( &mut self, pos: usize, size: usize, ) -> Result<(), InvalidFlatbuffer>

Source

pub fn in_buffer<T>(&mut self, pos: usize) -> Result<(), InvalidFlatbuffer>

Check that there really is a T in there.

Source

pub fn get_u8(&mut self, pos: usize) -> Result<u8, InvalidFlatbuffer>

Source

pub fn get_uoffset(&mut self, pos: usize) -> Result<UOffsetT, InvalidFlatbuffer>

Source

pub fn visit_table<'ver>( &'ver mut self, table_pos: usize, ) -> Result<TableVerifier<'ver, 'opts, 'buf>, InvalidFlatbuffer>

Source

pub fn verify_union_variant<T: Verifiable>( &mut self, variant: impl Into<Cow<'static, str>>, position: usize, ) -> Result<(), InvalidFlatbuffer>

Runs the union variant’s type’s verifier assuming the variant is at the given position, tracing the error.

Trait Implementations§

Source§

impl<'opts, 'buf> Debug for Verifier<'opts, 'buf>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'opts, 'buf> Freeze for Verifier<'opts, 'buf>

§

impl<'opts, 'buf> RefUnwindSafe for Verifier<'opts, 'buf>

§

impl<'opts, 'buf> Send for Verifier<'opts, 'buf>

§

impl<'opts, 'buf> Sync for Verifier<'opts, 'buf>

§

impl<'opts, 'buf> Unpin for Verifier<'opts, 'buf>

§

impl<'opts, 'buf> UnwindSafe for Verifier<'opts, 'buf>

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> 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, 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.