Skip to main content

Module decode

Module decode 

Source
Expand description

Decoding a payload from a bundle alone (spec core.md §7.1–§7.2), for tools that were never compiled against the contract.

  • Decode order (observer §7.3): a payload whose declared type the tool holds is decoded by that type, on the wire its sample’s Encoding names. Any other payload is sniffed.
  • protobuf decodes through the bundle’s FileDescriptorSet (prost-reflect), without codegen; jsonschema types are JSON or CBOR. Both render field by field, as JSON.
  • packed (core §7.6) reads through the bundle’s layout, under the tag the record’s envelope carried (Context): a record with no tag, or one its layout refuses, is undecodable with the refusal named.
  • Honest rendering: a raw type renders as its declared media type and the sample’s size, and bytes that do not decode as their declared type render as that type, the size and the reason. Neither garbage nor nothing.

Structs§

Context
What a reader holds of a payload beside its bytes and its Encoding: what a packed record is read with (core §7.6).

Enums§

Rendered
What a payload renders as.

Functions§

declared
A canonical type reference in the authoring spelling (spec §7.2, 0.8): the message name for protobuf, json:<name> for a JSON Schema type, the media type for a raw one. A tool names a type this way wherever it renders one, decoded or not.
decode
Decodes bytes of the type ty (a canonical type reference of bundle). encoding is the sample’s Encoding as zenoh spells it (application/json, application/cbor, application/protobuf, …), if any. A packed type decodes only with its envelope’s tag in hand: decode_in.
decode_in
decode, with what the reader holds beside the bytes: a packed record is read through the bundle’s layout under its envelope’s tag and the deployment epoch (core §7.6), refused by name as the layout refuses it.
epoch_assumed
The deployment epoch decode_in reads a record of ty under when cx states none: crate::packed::DEFAULT_EPOCH for a packed type whose layout holds a time field, None for every other type and whenever cx states one. Such a record’s time values are right only where the deployment’s epoch is that one (core §7.6 carries it nowhere yet; #980), so a tool that shows them says so beside them.
type_of
The canonical type reference of a resource’s member (type, attachment, request, response, error or summary), found by the resource’s kind token and template.