43 releases (12 stable)
|2.5.0||May 29, 2023|
|2.2.1||Apr 29, 2023|
|2.0.2||Mar 24, 2023|
|1.0.0-alpha.5||Jan 27, 2021|
|0.0.4||Dec 6, 2018|
#171 in Encoding
102,226 downloads per month
Used in 13 crates (10 directly)
sval: Streaming, structured values
sval is a lightweight serialization-only framework that treats values like a flat stream of tokens.
It's well suited to self-describing text formats like JSON.
How is this different from
serde is the de-facto serialization framework for Rust and is well suited to the majority of
sval is like a light blend of
serde::de that is smaller in scope.
It makes a few key different design decisions than
serde that make it effective for working with
- The API is flat rather than using recursion to stream nested datastructures.
- All values with dynamic sizes, including text strings, can be streamed in multiple calls.
- Borrowing is an optional optimization.
- The core data model is small, with tags for extensibility.
null: the absence of any other meaningful value.
- Text strings: stream of UTF8-encoded bytes.
- Binary strings: stream of arbtirary bytes.
- Binary floating point:
- Maps: heterogeneous collection of key-value pairs.
- Sequences: heterogeneous collection of values.
- Tags: out-of-band type hints.
- Tagged values: a tag associated with a value.
- Records: tagged maps where keys are well-known labels.
- Tuples: tagged sequences.
- Enums: tagged variants, where variants are enums, tags, tagged values, records, or tuples.
sval includes built-in tags that extend its data-model with some common datatypes:
- Rust primitives:
- Arbitrary-precision decimal floating point numbers.
Other built-in tags may be added in the future. Libraries may also define their own tags.
This project has a complete and stable API, but isn't well documented yet.