Skip to main content

solve_variant

Function solve_variant 

Source
pub fn solve_variant<'de>(
    shape: &'static Shape,
    parser: &mut dyn FormatParser<'de>,
) -> Result<Option<SolveOutcome>, SolveVariantError>
Expand description

Attempt to solve which enum variant matches the input.

This uses save/restore to read ahead and determine the variant without consuming the events permanently. After this returns, the parser position is restored so the actual deserialization can proceed.

Returns Ok(Some(_)) if a unique variant was found, Ok(None) if no variant matched, or Err(_) on error.