Expand description
Crate zerodds-wire-codec. Safety classification: SAFE.
One layout plan, one value, the bytes between them — in both directions, over any representation of a value.
§What is here and what is not
crate::encode() walks the plan and writes; crate::decode() walks
the same plan and reads. Neither decides a DHEADER, an EMHEADER, a
length code or a dialect answer: all of those are
zerodds_ast_layout’s, and a walk that decided them again would
agree with the plan only until one of the two changed.
crate::contract is the single answer to what a value means —
whether a key names a member, whether null is a value, whether an
integer is expressible — because three backends ask it and a
difference between their answers would be a difference in the sample
read as a difference in the serialisers.
§Why it is generic over the value
The walk was already generic on the type side: &Ast, an
Id<TypeNode> and a LayoutKey. It was concrete only on the value
side, against serde_json::Value, and a second value representation
— a DynamicData — would otherwise have needed a second copy of
every framing decision this crate makes once.
So the value side is two traits: source::Source for the direction
that reads a value and writes bytes, sink::Sink for the direction
that reads bytes and builds a value. zerodds-wire-probe implements
both for serde_json::Value.
Nothing here fixes a coordinate. A zerodds_ast_layout::WirePosition,
a dialect setting and a zerodds_ast::PrimitiveKind are arguments
at every site that has one, including inside the traits — a
representation that wants to know the width it is being handed is
told, and a representation that does not may ignore it. A coordinate
passed as a literal “because it is always the same here” is how the
framing defect survived five emitters.
§Layer position
A tool over zerodds-ast-layout and zerodds-wire. It names no
parser: turning IDL text into a model is the caller’s business.
Re-exports§
pub use canonical::Difference;pub use canonical::canonicalise;pub use decode::decode;pub use decode::decode_continuing;pub use decode::decode_prefix;pub use default::of_type as default_of_type;pub use encode::ProbeError;pub use encode::encode;pub use encode::encode_continuing;pub use sink::Aggregate;pub use sink::Sink;pub use source::Fields;pub use source::Source;pub use value::Emit;pub use value::ProbeRequest;pub use json::EXACT_JSON_INTEGER;
Modules§
- canonical
- The one form two implementations’ values can be compared in.
- contract
- What a value file means, in one place.
- decode
- The bytes back into the value.
- default
- The value a member takes when the stream does not carry it.
- encode
- One value, one type, the bytes between them.
- json
- What a value file is written in.
- sink
- What the read direction builds a value into.
- source
- What the write direction reads a value out of.
- value
- What a probe is asked for.
Constants§
- MAX_
VALUE_ DEPTH - How many nested aggregates a single value may hold before either walk refuses it.