A complex type under XCDR2 and XCDR1

A front-to-back round-trip of a real-world-shaped message under both wire representations.

What it shows

  • Sensor packs the constructs a hand-rolled codec usually gets wrong: a nested struct with a @key member, a bounded string<32>, an enum, a sequence of discriminated unions mixing all three arms, a map with a struct value, and an @optional member exercised both present and absent.
  • Sensor, Vec3 and Reading are @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.

Was es zeigt

  • Sensor bündelt die Konstrukte, an denen ein handgeschriebener Codec meist scheitert: ein verschachteltes Struct mit @key-Member, ein begrenztes string<32>, ein Enum, eine Sequence diskriminierter Unions über alle drei Zweige, eine map mit Struct-Wert und ein @optional-Member, einmal vorhanden und einmal nicht.
  • Sensor, Vec3 und Reading sind @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.

Verwandt