Expand description
sval zero-allocation streaming serialization adapter.
Gated by the sval feature.
sval adapter — stream noyalib values through any
[sval::Stream] consumer.
Provides an alternative to the default serde route for callers
who want to avoid serde_derive’s compile-time overhead or the
binary-size cost of serde monomorphisation. sval is a small,
streaming serialization framework: instead of materialising a
data graph, the producer walks the source and emits events on
a [sval::Stream] (similar in spirit to YAML’s own event-driven
parser).
Gated behind the sval Cargo feature.
§API surface
impl sval::Value for [crate::Value]— stream a noyalib value graph to any [sval::Stream].impl sval::Value for [crate::Number]— stream a single number.to_sval_writer— high-level helper that streams a noyalibcrate::Valueto a writer that implements [sval::Stream].
serde remains the default route for typed deserialise; sval
is an additive, opt-in surface for callers that prefer the
streaming framework. The two routes share Value, so a
roundtrip-via-Value works as expected.
§Non-finite floats
YAML’s .nan / .inf / -.inf literals deserialise into
Value::Number(Number::Float(f64::NAN | INFINITY | NEG_INFINITY)).
The default streaming behaviour forwards them verbatim to
sval::Stream::f64. Some sval consumers — notably
sval_json — reject non-finite floats at runtime. Callers
whose downstream cannot tolerate that should either filter
out non-finites before streaming, or wrap their sval::Stream
impl with a finite-coercion shim. The
to_sval_writer_with_config entry point exposes a
coerce_non_finite_to_null knob for top-level non-finite
scalars; nested non-finites land in a follow-up cut.
§Inverse direction
v0.0.6 ships the noyalib → sval direction only. A
sval → noyalib adapter (built on sval_buffer::Value) is
tracked for a follow-up cut; for now, callers that need to
ingest sval graphs into noyalib should go through serde or
the Value AST.
§Example
use noyalib::Value;
let v: Value = noyalib::from_str("name: noyalib").unwrap();
// The `impl sval::Value for Value` lets you hand any
// noyalib-parsed graph to any `sval::Stream` consumer.
// Concrete stream impls are supplied by ecosystem crates
// such as `sval_fmt`, `sval_json`, or your own — noyalib
// does not pull those in.
assert!(matches!(v, Value::Mapping(_)));Structs§
- Sval
Config - Knobs for
to_sval_writer_with_config.
Functions§
- to_
sval_ writer - Stream a
Valueinto a writer that implements [sval::Stream]. - to_
sval_ writer_ with_ config to_sval_writerwith caller-supplied knobs.