pub struct Context<'de> {
pub arena: &'de Arena,
pub errors: Vec<Error>,
/* private fields */
}from-toml only.Expand description
Shared state that accumulates errors and holds the arena.
Created by parse and stored inside
Document. Pass it into TableHelper::new or
Item::table_helper when implementing FromToml.
Multiple errors can be recorded during a single conversion pass.
Inspect them via Document::errors.
Fields§
§arena: &'de Arena§errors: Vec<Error>Implementations§
Source§impl<'de> Context<'de>
impl<'de> Context<'de>
Sourcepub fn report_expected_but_found(
&mut self,
message: &'static &'static str,
found: &Item<'de>,
) -> Failed
pub fn report_expected_but_found( &mut self, message: &'static &'static str, found: &Item<'de>, ) -> Failed
Records a “expected X, found Y” type-mismatch error and returns Failed.
Sourcepub fn report_unexpected_variant(
&mut self,
expected: &'static [&'static str],
found: &Item<'de>,
) -> Failed
pub fn report_unexpected_variant( &mut self, expected: &'static [&'static str], found: &Item<'de>, ) -> Failed
Records an “unknown variant” error listing the accepted variants and returns Failed.
Sourcepub fn report_error_at(&mut self, message: &'static str, at: Span) -> Failed
pub fn report_error_at(&mut self, message: &'static str, at: Span) -> Failed
Records a custom error message at the given span and returns Failed.
Sourcepub fn push_error(&mut self, error: Error) -> Failed
pub fn push_error(&mut self, error: Error) -> Failed
Sourcepub fn report_custom_error(
&mut self,
error: impl ToString,
item: &Item<'de>,
) -> Failed
pub fn report_custom_error( &mut self, error: impl ToString, item: &Item<'de>, ) -> Failed
Sourcepub fn report_out_of_range(
&mut self,
ty: &'static &'static str,
range: &'static &'static str,
found: &Item<'de>,
) -> Failed
pub fn report_out_of_range( &mut self, ty: &'static &'static str, range: &'static &'static str, found: &Item<'de>, ) -> Failed
Records an out-of-range error for the type name and returns Failed.
Sourcepub fn report_missing_field(
&mut self,
name: &'static str,
item: &Item<'de>,
) -> Failed
pub fn report_missing_field( &mut self, name: &'static str, item: &Item<'de>, ) -> Failed
Records a missing-field error and returns Failed.
Used by generated FromToml implementations that iterate over table
entries instead of using TableHelper.
Sourcepub fn report_duplicate_field(
&mut self,
name: &'static str,
key_span: Span,
first_key_span: Span,
item: &Item<'de>,
) -> Failed
pub fn report_duplicate_field( &mut self, name: &'static str, key_span: Span, first_key_span: Span, item: &Item<'de>, ) -> Failed
Records a duplicate-field error and returns Failed.
Used by generated FromToml implementations when a field with aliases
is set more than once (e.g. both the primary key and an alias appear).
Sourcepub fn report_deprecated_field(
&mut self,
tag: u32,
old: &'static &'static str,
new: &'static &'static str,
key_span: Span,
item: &Item<'de>,
)
pub fn report_deprecated_field( &mut self, tag: u32, old: &'static &'static str, new: &'static &'static str, key_span: Span, item: &Item<'de>, )
Records a deprecated-field warning with TOML path information.
Unlike other report_* methods this is non-fatal: it pushes
an error but does not return Failed, so deserialization continues.