pub trait FormatParser<'de> {
type Error;
type Probe<'a>: ProbeStream<'de, Error = Self::Error>
where Self: 'a;
// Required methods
fn next_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>;
fn peek_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>;
fn skip_value(&mut self) -> Result<(), Self::Error>;
fn begin_probe(&mut self) -> Result<Self::Probe<'_>, Self::Error>;
// Provided methods
fn capture_raw(&mut self) -> Result<Option<&'de str>, Self::Error> { ... }
fn raw_capture_shape(&self) -> Option<&'static Shape> { ... }
}Expand description
Streaming parser for a specific wire format.
Required Associated Types§
Sourcetype Probe<'a>: ProbeStream<'de, Error = Self::Error>
where
Self: 'a
type Probe<'a>: ProbeStream<'de, Error = Self::Error> where Self: 'a
Evidence cursor type produced by FormatParser::begin_probe.
Required Methods§
Sourcefn next_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>
fn next_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>
Read the next parse event.
Sourcefn peek_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>
fn peek_event(&mut self) -> Result<ParseEvent<'de>, Self::Error>
Peek at the next event without consuming it.
Sourcefn skip_value(&mut self) -> Result<(), Self::Error>
fn skip_value(&mut self) -> Result<(), Self::Error>
Skip the current value (for unknown fields, etc.).
Sourcefn begin_probe(&mut self) -> Result<Self::Probe<'_>, Self::Error>
fn begin_probe(&mut self) -> Result<Self::Probe<'_>, Self::Error>
Begin evidence collection for untagged-enum resolution.
Provided Methods§
Sourcefn capture_raw(&mut self) -> Result<Option<&'de str>, Self::Error>
fn capture_raw(&mut self) -> Result<Option<&'de str>, Self::Error>
Capture the raw representation of the current value without parsing it.
This is used for types like RawJson that want to defer parsing.
The parser should skip the value and return the raw bytes/string
from the input.
Returns Ok(None) if raw capture is not supported (e.g., streaming mode
or formats where raw capture doesn’t make sense).
Sourcefn raw_capture_shape(&self) -> Option<&'static Shape>
fn raw_capture_shape(&self) -> Option<&'static Shape>
Returns the shape of the format’s raw capture type (e.g., RawJson::SHAPE).
When the deserializer encounters a shape that matches this, it will use
capture_raw to capture the raw representation and store it in a
Cow<str> (the raw type must be a newtype over Cow<str>).
Returns None if this format doesn’t support raw capture types.
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.