A complex type under XCDR2 and XCDR1
A front-to-back round-trip of a real-world-shaped message under both wire representations.
- Example:
rust-complex-types-roundtrip - Repository: zero-dds-snippets
What it shows
Sensorpacks the constructs a hand-rolled codec usually gets wrong: a nested struct with a@keymember, a boundedstring<32>, an enum, a sequence of discriminated unions mixing all three arms, amapwith a struct value, and an@optionalmember exercised both present and absent.Sensor,Vec3andReadingare@appendable, so the two representations differ structurally, not just in alignment: XCDR2 delimits an appendable aggregate with a DHEADER and caps 8-byte primitives at 4-byte alignment; XCDR1 writes no DHEADER and uses natural 8-byte alignment.
Build and run
cargo run
Output
optional present:
[XCDR2] 218 bytes — round-trip OK
[XCDR1] 200 bytes — round-trip OK
optional absent:
[XCDR2] 189 bytes — round-trip OK
[XCDR1] 172 bytes — round-trip OK
all complex-type round-trips pass under both XCDR2 and XCDR1 ✓
Measured on the internal RC7 preparation sources on 2026-09-12 and recorded in the example README. This in-process Rust example checks decoded values, not cross-vendor or cross-language byte identity.
See also
Ein komplexer Typ unter XCDR2 und XCDR1
Ein Roundtrip von vorn bis hinten für eine praxisnah geformte Nachricht unter beiden Wire-Repräsentationen.
- Beispiel:
rust-complex-types-roundtrip - Repository: zero-dds-snippets
Was es zeigt
Sensorbündelt die Konstrukte, an denen ein handgeschriebener Codec meist scheitert: ein verschachteltes Struct mit@key-Member, ein begrenztesstring<32>, ein Enum, eine Sequence diskriminierter Unions über alle drei Zweige, einemapmit Struct-Wert und ein@optional-Member, einmal vorhanden und einmal nicht.Sensor,Vec3undReadingsind@appendable, also unterscheiden sich die beiden Repräsentationen strukturell und nicht nur im Alignment: XCDR2 rahmt ein appendable-Aggregat mit DHEADER und deckelt 8-Byte-Primitive auf 4-Byte-Alignment; XCDR1 schreibt keinen DHEADER und nutzt natürliches 8-Byte-Alignment.
Bauen und ausführen
cargo run
Ausgabe
optional present:
[XCDR2] 218 bytes — round-trip OK
[XCDR1] 200 bytes — round-trip OK
optional absent:
[XCDR2] 189 bytes — round-trip OK
[XCDR1] 172 bytes — round-trip OK
all complex-type round-trips pass under both XCDR2 and XCDR1 ✓
Am internen RC7-Vorbereitungsstand am 2026-09-12 gemessen und im Beispiel-README festgehalten. Dieses Rust-Beispiel prüft dekodierte Werte im selben Prozess, keine hersteller- oder sprachübergreifende Byteidentität.