Struct fourleaf::de::Context [] [src]

pub struct Context<'a> {
    pub next: Option<&'a Context<'a>>,
    pub field: &'a str,
    pub pos: u64,
    pub depth: usize,
    pub config: &'a Config,
    // some fields omitted
}

Tracks contextual information during deserialisation.

This is used for constructing helpful error messages and controlling recursion depth and other limits. Note that this does use interior mutability, so it is unwise to reuse the same Context for deserialising more than one object.

Context objects are typically constructed on the stack and passed to sub-deserialisers by reference.

A Context can be formatted with Display to show the path to the current location, including both field names and offsets.

Fields

The context for the "container" of this level of deserialisation, if any.

The name of the field being deserialised at this level.

The position of the field being deserialised at this level.

The recursion depth.

The configuration to use when deserialising this level's immediate children.

Methods

impl<'a> Context<'a>
[src]

Returns a "top-level" context referencing the given config.

Creates a context subordinate to this one for the given field, provided it does not exceed the recursion limit.

Like push(), but the name of the field is the base-10 representation of tag saved in data.

If unknown fields are to result in an error, return such an error. Otherwise, return Ok(()).

If the current running collection count plus n is less than or equal to max_collect, update the running collection count and return Ok. Otherwise, return an error.

If the current running blob size sum plus n is less than or equal to max_blob, update the running sum and return Ok. Otherwise, return an error.

Trait Implementations

impl<'a> Debug for Context<'a>
[src]

Formats the value using the given formatter.

impl<'a> Clone for Context<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> Display for Context<'a>
[src]

Formats the value using the given formatter. Read more