Skip to main content

Module envelope

Module envelope 

Source
Expand description

The shared durable envelope codec: probe, validation rules, JSON codec, and the one error vocabulary every family reports through.

Published so a durable format outside this crate — a first-party extension’s own objects — parameterizes the same codec instead of copying it and drifting from the rules in section 4 of the format spec.

Structs§

DecodedJsonEnvelope
A decoded JSON-bodied envelope’s shared fields plus its parsed payload.
EnvelopeProbe
Identifying prefix of a durable envelope document.

Enums§

EnvelopeCodecError
Failure vocabulary shared by every envelope codec. Messages are envelope-generic; the wrapping error names the object (and its key) the bytes came from.

Functions§

decode_json_envelope
Decodes one JSON-bodied envelope: probe first (kind through classify_kind, then version), then the checksum over the stored payload fragment, then the payload itself.
decode_strict_json_envelope
Immutable envelope families tolerate unknown fields, while mutable control-object envelopes reject them. A tolerant read followed by rewrite would erase fields the current binary does not understand.
encode_json_envelope
Encodes one JSON-bodied envelope, validating that the recorded version is what this build writes for kind and that the recorded checksum still matches the payload.
json_payload_checksum
The sha256:<hex> checksum a JSON payload will carry, computed over its canonical serialization.
verify_checksum_fresh
Requires an in-memory envelope’s recorded checksum to still match its payload before encoding — a stale checksum means the caller mutated the payload without rebuilding the envelope.
verify_kind
Requires the probed kind to be exactly expected.
verify_payload_checksum
Requires the stored checksum to match the payload bytes as stored.
verify_version
Requires the probed format version to be exactly what this build writes for kind — no envelope family tolerates version skew.