pub struct RecoveryContext<'a> { /* private fields */ }Expand description
Projection scope that records unknown required tags and missing required fields.
Projectors still validate each known descendant. The scope owns only the compatibility result and borrows the same admission meter as its parent.
Implementations§
Source§impl RecoveryContext<'_>
impl RecoveryContext<'_>
Sourcepub fn check<R>(
context: &ReadContext<'_>,
project: impl FnOnce(&RecoveryContext<'_>) -> Result<R, Error>,
) -> Result<R, Error>
pub fn check<R>( context: &ReadContext<'_>, project: impl FnOnce(&RecoveryContext<'_>) -> Result<R, Error>, ) -> Result<R, Error>
Check a projection with no enclosing option for a marked incompatibility.
§Errors
Returns a projection error first. Returns Error::Incompatible if the projection completes with a marked incompatibility outside a recovering branch.
Sourcepub const fn read_context(&self) -> &ReadContext<'_>
pub const fn read_context(&self) -> &ReadContext<'_>
Borrow the current context for ordinary projection and nested branches.
Sourcepub fn nested<R>(
&self,
project: impl FnOnce(&RecoveryContext<'_>) -> Result<R, Error>,
) -> Result<R, Error>
pub fn nested<R>( &self, project: impl FnOnce(&RecoveryContext<'_>) -> Result<R, Error>, ) -> Result<R, Error>
Admit one additional structural level within this scope.
§Errors
Returns the depth or work refusal or a projection error.
Sourcepub fn project_field<'de, T: Deserialize<'de>, R>(
&self,
field: Field<'_, 'de>,
project: impl FnOnce(T, &RecoveryContext<'_>) -> Result<R, Error>,
) -> Result<R, Error>
pub fn project_field<'de, T: Deserialize<'de>, R>( &self, field: Field<'_, 'de>, project: impl FnOnce(T, &RecoveryContext<'_>) -> Result<R, Error>, ) -> Result<R, Error>
Project a known field at its own admitted depth within this scope.
§Errors
Returns a typed field error or a projection error. A field from a different admission context is malformed.
Sourcepub fn missing_required(&self)
pub fn missing_required(&self)
Mark a missing required extension in the reader’s schema.
Call this only after a complete extension visit has validated every entry header and known value. Continue projecting the remaining known siblings and propagate their errors.
Sourcepub fn required_open<'de, R>(
&self,
open: OpaqueOpen<'de>,
visit: impl FnOnce(u32, Field<'_, 'de>) -> Result<Option<R>, Error>,
) -> Result<Option<R>, Error>
pub fn required_open<'de, R>( &self, open: OpaqueOpen<'de>, visit: impl FnOnce(u32, Field<'_, 'de>) -> Result<Option<R>, Error>, ) -> Result<Option<R>, Error>
Map a required open variant and mark a well-formed unknown tag.
Return None from the callback only for unknown tags. Known tags must check their typed payloads. The result is absent until the enclosing projection decides whether it can return the full value.
§Errors
Returns malformed for a zero tag, and propagates allowance and callback errors.