Skip to main content

Message

Struct Message 

Source
pub struct Message<'b> { /* private fields */ }

Implementations§

Source§

impl<'b> Message<'b>

Source

pub fn parse(buf: &'b [u8]) -> Result<Message<'b>>

Source

pub fn buffer(&self) -> &'b [u8]

Source

pub fn schema_id(&self) -> u128

Source

pub fn root_offset(&self) -> u32

Absolute offset of the root struct block. Exposed for generated code (the codegen identity fast path reads at constant offsets from here).

Source

pub fn has_inline_schema(&self) -> bool

Source

pub fn writer_schema(&self) -> Result<Option<Schema>>

Decode the inline writer schema, if the message carries one. The decoded schema’s content hash must match the header’s schema id.

Source

pub fn root<'r>(&self, resolver: &'r Resolver) -> Result<StructReader<'b, 'r>>

Open the root struct through a resolver whose writer schema matches this message’s schema id. Unbounded: reads are memory-safe but do not cap total traversal work — use this for trusted data or after an upstream size cap. For untrusted input, prefer Self::root_bounded.

Source

pub fn root_bounded<'r>( &self, resolver: &'r Resolver, budget: &'r Budget, ) -> Result<StructReader<'b, 'r>>

Open the root struct with a Budget that caps total traversal work, guarding against amplification-DoS on untrusted input (the wire spec §5.2). The budget outlives the returned readers, which charge every byte they touch against it.

Source

pub fn verify(&self, resolver: &Resolver, budget: &Budget) -> Result<()>

Walk the whole message once under a Budget, touching every reachable field and element, and return Ok(()) iff the traversal stays within budget (and depth). This is the guard for the fast/codegen path: verify untrusted bytes once, and if it passes, a single subsequent zero-copy scan — via the generated readers or Self::root — cannot amplify beyond the budget, because a full scan touches no more than this walk did. Trusted data skips it and pays nothing. (Analogous to FlatBuffers’ verified root, but Veritate needs no separate encoding — the same bytes are then read directly.)

Source

pub fn suggested_budget(&self) -> u64

A sensible default traversal-budget limit for this message: max(64 KiB, 64 × message length). Scales with legitimate message size (a well-formed message touches ~its own size once), leaving generous headroom while capping amplification at ~64× the bytes on the wire.

Trait Implementations§

Source§

impl<'b> Clone for Message<'b>

Source§

fn clone(&self) -> Message<'b>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'b> Debug for Message<'b>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'b> Freeze for Message<'b>

§

impl<'b> RefUnwindSafe for Message<'b>

§

impl<'b> Send for Message<'b>

§

impl<'b> Sync for Message<'b>

§

impl<'b> Unpin for Message<'b>

§

impl<'b> UnsafeUnpin for Message<'b>

§

impl<'b> UnwindSafe for Message<'b>

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.