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
next: Option<&'a Context<'a>>
The context for the "container" of this level of deserialisation, if any.
field: &'a str
The name of the field being deserialised at this level.
pos: u64
The position of the field being deserialised at this level.
depth: usize
The recursion depth.
config: &'a Config
The configuration to use when deserialising this level's immediate children.
Methods
impl<'a> Context<'a>
[src]
fn top(config: &'a Config) -> Self
Returns a "top-level" context referencing the given config.
fn push(&'a self, field: &'a str, pos: u64) -> Result<Self>
Creates a context subordinate to this one for the given field, provided it does not exceed the recursion limit.
fn push_tag(&'a self, name: &'a mut [u8; 2], tag: u8, pos: u64) -> Result<Self>
Like push()
, but the name of the field is the base-10 representation
of tag
saved in data
.
fn unknown_field<R>(&self, field: &Field<R>) -> Result<()>
If unknown fields are to result in an error, return such an error.
Otherwise, return Ok(())
.
fn collect(&self, n: usize) -> Result<()>
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.
fn blob(&self, n: u64) -> Result<()>
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]
impl<'a> Clone for Context<'a>
[src]
fn clone(&self) -> Context<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more