Skip to main content

Module decode

Module decode 

Source
Expand description

The bytes back into the value.

encode.rs walks the layout plan and writes; this walks the same plan and reads. Not a second reading of the model, for the reason the encoder gives: two walks that decided the framing separately would agree with each other only until one of them changed.

§What the return direction adds

Encoding is measured by comparing bytes, and a byte comparison passes a decoder that is wrong in the same way its own encoder is wrong. A round trip through one implementation passes such a defect every time; a round trip through two does not. That is the whole reason this file exists — docs/specs/zerodds-interop-suite-1.0.md §4, P2.

§Where reading needs a decision writing did not

Two places, each of which the writer never had to face:

  • A union’s member. The writer takes the member the value names; the reader has only the discriminator, so it evaluates the case labels against it, falls back to default:, and reads no member at all where neither matches.
  • The end of the stream. A decoder that stopped early would leave bytes unread and report success, which is the failure class this suite exists to find. Anything left over is an error.

Functions§

decode
Read bytes as request.type_name, in canonical form.
decode_continuing
As decode, for a value that begins at start in bytes: alignment counts from the start of bytes, the sample.
decode_prefix
Read one value of request.type_name from the start of bytes and say how many octets it took.
key_holder
Decode an actual PLAIN_CDR2-BE holder using the shared member plan and defaults.
key_holder_prefix
Decode a PLAIN_CDR2-BE holder from the start of bytes and say how many octets it took; what follows is the caller’s (DDSI-RTPS 2.5 §9.6.4.8 Step 5.1: a KeyHash is the holder padded with zeros to 16 octets).
padding_present
The number of padding octets an encapsulated payload of payload_len octets (encapsulation header included) carries at its end, given the low byte of its options word.
serialized_key
Decode the writer’s own serializedKey (DDSI-RTPS 2.5 §9.4.2.11) — the key-only payload behind a dispose/unregister DATA’s K flag — in the representation and byte order request names.
validate_key_holder
Validate the currently supported inverse holder shape without reading data.