Crate facet_deserialize

Source
Expand description

Facet logo - a reflection library for Rust

Coverage Status free of syn crates.io documentation MIT/Apache-2.0 licensed Discord

Logo by Misiasart

Thanks to all individual and corporate sponsors, without whom this work could not exist:

Ko-fi GitHub Sponsors Patreon Zed Depot

§facet-deserialize

An event-based approach to facet-deserialize

§License

Licensed under either of:

at your option.

Structs§

DeserError
A JSON parse error, with context. Never would’ve guessed huh.
DeserErrorMessage
A wrapper type for displaying deser error messages
NextData
Carries the current parsing state and the in-progress value during deserialization. This bundles the mutable context that must be threaded through parsing steps.
Span
A span in the input, with a start position and length
Spanned
A value of type T annotated with its Span
Subspan
A Subspan variant of a Span
Substack
Container for subspans based on span type

Enums§

Cooked
A Cooked variant of a Span (byte indexed)
DeserErrorKind
An error kind for JSON parsing.
Expectation
Expected next input token or structure during deserialization.
Instruction
Instructions guiding the parsing flow, indicating the next expected action or token.
Outcome
Outcome of parsing the next input element.
PopReason
Reasons for popping a state from the stack, indicating why a scope is ended.
Raw
A Raw variant of a Span (format-specific index)
Scalar
A scalar value used during deserialization. u64 and i64 are separated because i64 doesn’t fit in u64, but having u64 is a fast path for 64-bit architectures — no need to go through u128 / i128 for everything
SubspanMeta
Metadata about a subspan, providing context for how the subspan relates to the parent span or other subspans.
ValueReason
Reasons for expecting a value, reflecting the current parse context.

Traits§

Format
Trait defining a deserialization format. Provides the next parsing step based on current state and expected input.
InputDebug
Trait for handling input data in error reporting and debugging. Provides methods to convert input slices to human-readable strings and to create byte arrays for error storage.
Spannable
Trait for types that can be annotated with a Span.
SubstackBehavior
This trait allows the compiler to optimize away Substack-related code for formats with span types that don’t use subspans, making it zero-cost.
ToCooked
Trait handling conversion regardless of Format::SpanType to Span<Cooked>

Functions§

deserialize
Deserialize a value of type T from raw input bytes using format F.
deserialize_wip
Deserializes a working-in-progress value into a fully materialized heap value. This function drives the parsing loop until the entire input is consumed and the value is complete.

Type Aliases§

NextResult
The result of advancing the parser: updated state and parse outcome or error.
Pos
Position in the input (byte index)