pub struct FormatDeserializer<'parser, 'input, const BORROW: bool> { /* private fields */ }Expand description
Generic deserializer that drives a format-specific parser directly into Partial.
The const generic BORROW controls whether string data can be borrowed:
BORROW=true: strings without escapes are borrowed from inputBORROW=false: all strings are owned
The lifetime 'parser is the lifetime of the parser itself, which may be shorter
than 'input (e.g., for streaming parsers that produce owned data but contain
references to internal state).
Implementations§
Source§impl<'parser, 'input, const BORROW: bool> FormatDeserializer<'parser, 'input, BORROW>
impl<'parser, 'input, const BORROW: bool> FormatDeserializer<'parser, 'input, BORROW>
Sourcepub fn deserialize_into(
&mut self,
wip: Partial<'input, BORROW>,
meta: MetaSource<'input>,
) -> Result<Partial<'input, BORROW>, DeserializeError>
pub fn deserialize_into( &mut self, wip: Partial<'input, BORROW>, meta: MetaSource<'input>, ) -> Result<Partial<'input, BORROW>, DeserializeError>
Main deserialization entry point - deserialize into a Partial.
Uses the precomputed DeserStrategy from TypePlan for fast dispatch.
The strategy is computed once at Partial allocation time, eliminating
repeated runtime inspection of Shape/Def/vtable during deserialization.
The meta parameter specifies where metadata should come from:
MetaSource::Explicit(meta)- use provided metadata from outer contextMetaSource::FromEvents- read fresh metadata from the events being parsed
Sourcepub fn deserialize_into_with_shape(
&mut self,
wip: Partial<'input, BORROW>,
hint_shape: &'static Shape,
) -> Result<Partial<'input, BORROW>, DeserializeError>
pub fn deserialize_into_with_shape( &mut self, wip: Partial<'input, BORROW>, hint_shape: &'static Shape, ) -> Result<Partial<'input, BORROW>, DeserializeError>
Deserialize using an explicit source shape for parser hints.
This walks hint_shape for control flow and parser hints, but builds
into the wip Partial (which should be a DynamicValue like Value).
Source§impl<'parser, 'input> FormatDeserializer<'parser, 'input, true>
impl<'parser, 'input> FormatDeserializer<'parser, 'input, true>
Sourcepub fn new(parser: &'parser mut dyn FormatParser<'input>) -> Self
pub fn new(parser: &'parser mut dyn FormatParser<'input>) -> Self
Create a new deserializer that can borrow strings from input.
Sourcepub fn with_buffer_capacity(
parser: &'parser mut dyn FormatParser<'input>,
buffer_capacity: usize,
) -> Self
pub fn with_buffer_capacity( parser: &'parser mut dyn FormatParser<'input>, buffer_capacity: usize, ) -> Self
Create a new deserializer with a custom buffer capacity.
Source§impl<'parser, 'input> FormatDeserializer<'parser, 'input, false>
impl<'parser, 'input> FormatDeserializer<'parser, 'input, false>
Sourcepub fn new_owned(parser: &'parser mut dyn FormatParser<'input>) -> Self
pub fn new_owned(parser: &'parser mut dyn FormatParser<'input>) -> Self
Create a new deserializer that produces owned strings.
Sourcepub fn with_buffer_capacity_owned(
parser: &'parser mut dyn FormatParser<'input>,
buffer_capacity: usize,
) -> Self
pub fn with_buffer_capacity_owned( parser: &'parser mut dyn FormatParser<'input>, buffer_capacity: usize, ) -> Self
Create a new deserializer with a custom buffer capacity.
Source§impl<'parser, 'input, const BORROW: bool> FormatDeserializer<'parser, 'input, BORROW>
impl<'parser, 'input, const BORROW: bool> FormatDeserializer<'parser, 'input, BORROW>
Sourcepub fn parser_mut(&mut self) -> &mut dyn FormatParser<'input>
pub fn parser_mut(&mut self) -> &mut dyn FormatParser<'input>
Borrow the inner parser mutably.
Source§impl<'parser, 'input> FormatDeserializer<'parser, 'input, true>
impl<'parser, 'input> FormatDeserializer<'parser, 'input, true>
Sourcepub fn deserialize<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
pub fn deserialize<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
Deserialize the next value in the stream into T, allowing borrowed strings.
Sourcepub fn deserialize_root<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
pub fn deserialize_root<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
Deserialize the next value in the stream into T (for backward compatibility).
Sourcepub fn deserialize_deferred<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
pub fn deserialize_deferred<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'input>,
Deserialize using deferred mode, allowing interleaved field initialization.
This is required for formats like TOML that allow table reopening, where fields of a nested struct may be set, then fields of a sibling, then more fields of the original struct.
Source§impl<'parser, 'input> FormatDeserializer<'parser, 'input, false>
impl<'parser, 'input> FormatDeserializer<'parser, 'input, false>
Sourcepub fn deserialize<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
pub fn deserialize<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
Deserialize the next value in the stream into T, using owned strings.
Sourcepub fn deserialize_root<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
pub fn deserialize_root<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
Deserialize the next value in the stream into T (for backward compatibility).
Sourcepub fn deserialize_deferred<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
pub fn deserialize_deferred<T>(&mut self) -> Result<T, DeserializeError>where
T: Facet<'static>,
Deserialize using deferred mode, allowing interleaved field initialization.
This is required for formats like TOML that allow table reopening, where fields of a nested struct may be set, then fields of a sibling, then more fields of the original struct.
Sourcepub fn deserialize_with_shape<T>(
&mut self,
source_shape: &'static Shape,
) -> Result<T, DeserializeError>where
T: Facet<'static>,
pub fn deserialize_with_shape<T>(
&mut self,
source_shape: &'static Shape,
) -> Result<T, DeserializeError>where
T: Facet<'static>,
Deserialize using an explicit source shape for parser hints.
This is useful for non-self-describing formats like postcard where you need to decode data that was serialized using a specific type, but you only have the shape information at runtime (not the concrete type).
The target type T should typically be a DynamicValue like facet_value::Value.