Expand description
Reflective XCDR codec: CDR bytes ⟷ DynamicData, driven by a runtime
DynamicType.
The DDS CDR codec is mature + interop-hardened (the 4-vendor ×
3-extensibility matrix) but monomorphic — DdsType::decode per generated
Rust type. This module is the missing reflective path: it walks a runtime
DynamicType and reuses the SAME hardened wire framing from
zerodds_cdr::struct_enc (decode_appendable / read_all_mutable_members +
encode_appendable / encode_mutable_member) and the BufferReader /
BufferWriter primitives. No DHEADER/EMHEADER/alignment logic is
reimplemented — only the type-driven member walk lives here.
Supported (both directions, byte-exact round-trip tested):
- primitives, enum,
string,wstring(via the hardenedzerodds_cdr::WString); - struct FINAL / APPENDABLE / MUTABLE; nested struct;
- union FINAL / APPENDABLE / MUTABLE (PL_CDR2: discriminator = EMHEADER member id 0, selected branch = its own EMHEADER member), with the discriminator encoded at its REAL kind (bool/char/int8/16/32/64/enum — not int32);
- sequences + arrays of scalar AND composite (struct/union) elements, incl.
the XCDR2 collection DHEADER for non-primitive elements. Composite element
types are carried via
crate::dynamic::collection(a resolved elementDynamicType); scalar elements are rebuilt from the shallow descriptor. - alias (typedef) members whose target is a scalar (composite typedefs are resolved to their underlying type at IDL-lowering time).
Residual (honest NotSupported, never silent-wrong):
long double/Float128— blocked on stable Rustf128;bitmask/bitsetare lowered to their underlying wire integer at IDL-lowering time (so they decode correctly as integers); the codec keeps no dedicated kind for them.
Enums§
- Codec
Error - Reflective-codec error.
Functions§
- decode_
dynamic - Decode
bytes(a CDR payload WITHOUT the encapsulation header) into aDynamicDataofty.xcdr2selects XCDR2 vs XCDR1 framing;big_endianthe byte order — both come from the sample’s encapsulation id on the wire. - encode_
dynamic - Encode
datato a CDR payload (WITHOUT the encapsulation header), the mirror ofdecode_dynamic:encode_dynamic(decode_dynamic(ty, b, x, e)?, x, e)? == b.