Trait Format

Source
pub trait Format {
    type Input<'input>: ?Sized;

    // Required methods
    fn source(&self) -> &'static str;
    fn next<'input, 'facet>(
        &mut self,
        nd: NextData<'input, 'facet, Self::Input<'input>>,
        expectation: Expectation,
    ) -> NextResult<'input, 'facet, Spanned<Outcome<'input>>, Spanned<DeserErrorKind>, Self::Input<'input>>;
    fn skip<'input, 'facet>(
        &mut self,
        nd: NextData<'input, 'facet, Self::Input<'input>>,
    ) -> NextResult<'input, 'facet, Span, Spanned<DeserErrorKind>, Self::Input<'input>>;
}
Expand description

Trait defining a deserialization format. Provides the next parsing step based on current state and expected input.

Required Associated Types§

Source

type Input<'input>: ?Sized

The kind of input this format consumes, parameterized by input lifetime.

  • JsonFmt => Input<'input> = [u8]
  • CliFmt => Input<'input> = [&'input str]

Required Methods§

Source

fn source(&self) -> &'static str

The lowercase source ID of the format, used for error reporting.

Source

fn next<'input, 'facet>( &mut self, nd: NextData<'input, 'facet, Self::Input<'input>>, expectation: Expectation, ) -> NextResult<'input, 'facet, Spanned<Outcome<'input>>, Spanned<DeserErrorKind>, Self::Input<'input>>

Advance the parser with current state and expectation, producing the next outcome or error.

Source

fn skip<'input, 'facet>( &mut self, nd: NextData<'input, 'facet, Self::Input<'input>>, ) -> NextResult<'input, 'facet, Span, Spanned<DeserErrorKind>, Self::Input<'input>>

Skip the next value; used to ignore an input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§