Skip to main content

Context

Struct Context 

Source
pub struct Context<'de> {
    pub arena: &'de Arena,
    pub errors: Vec<Error>,
    /* private fields */
}
Expand description

Shared deserialization state that accumulates errors and holds the arena.

A Context is created by parse and lives inside Root. Pass it into TableHelper::new or Item::table_helper when implementing Deserialize.

Multiple errors can be recorded during a single deserialization pass; inspect them afterwards via Root::errors.

Fields§

§arena: &'de Arena§errors: Vec<Error>

Implementations§

Source§

impl<'de> Context<'de>

Source

pub fn error_expected_but_found( &mut self, message: &'static str, found: &Item<'_>, ) -> Failed

Records a “expected X, found Y” type-mismatch error and returns Failed.

Source

pub fn error_message_at(&mut self, message: &'static str, at: Span) -> Failed

Records a custom error message at the given span and returns Failed.

Source

pub fn push_error(&mut self, error: Error) -> Failed

Pushes a pre-built Error and returns Failed.

Source

pub fn error_out_of_range(&mut self, name: &'static str, span: Span) -> Failed

Records an out-of-range error for the type name and returns Failed.

Auto Trait Implementations§

§

impl<'de> Freeze for Context<'de>

§

impl<'de> !RefUnwindSafe for Context<'de>

§

impl<'de> !Send for Context<'de>

§

impl<'de> !Sync for Context<'de>

§

impl<'de> Unpin for Context<'de>

§

impl<'de> UnsafeUnpin for Context<'de>

§

impl<'de> !UnwindSafe for Context<'de>

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.