Skip to main content

serialized_key

Function serialized_key 

Source
pub fn serialized_key<V: Source>(
    ast: &Ast,
    request: &ProbeRequest,
    values: &V,
) -> Result<Vec<u8>, ProbeError>
Expand description

Encode the writer’s own serializedKey (DDSI-RTPS 2.5 §9.4.2.11) — the key-only payload a dispose/unregister DATA carries behind its K flag — in the representation and byte order request names.

The exact inverse of crate::decode::serialized_key: the same Purpose::Key plus request.key_holder/key_holder_order/ key_holder_nesting (AsDeclared + Declaration, Recursive nesting already the default) select the type’s own extensibility framing (a DHEADER for @appendable/@mutable under XCDR2, a per-member EMHEADER for @mutable, nothing for @final or under XCDR1) and declaration order, in request’s own encoding and endianness — not the canonical big-endian PLAIN_CDR2 form key_holder always writes.

values needs only the @key members populated: write_aggregate walks plan()’s already-filtered member list (the same Purpose::Key “holder” plan key_holder’s canonical form uses, just under a different key_holder/key_holder_order), so a non-key member is never looked up.

Emit::PayloadWithEncapsulation wraps the result behind the four-byte encapsulation header and zero-pads it to a four-byte boundary, with the pad count in the header’s low two option bits (XTypes 1.3 §7.6.3.1.2) — the same convention encode uses for a full sample.

§Errors

ProbeError: the type is not in the model, plan() cannot describe it under this key, or a @key member’s value is missing or refused.