pub enum Encoding {
PlainCdr1,
PlCdr1,
PlainCdr2,
DelimitedCdr,
PlCdr2,
}Expand description
Which encoding a plan is computed for.
XCDR1 and XCDR2 differ in their framing: XCDR1 has no delimiter
header, and @mutable uses PID headers there and EMHEADERs here.
Primitive alignment is the same in both. OMG XTypes 1.3 §7.4.
Variants§
PlainCdr1
XCDR1 without a parameter list. XTypes 1.3 §7.4.1.
PlCdr1
XCDR1 with a parameter list, for @mutable. XTypes 1.3 §7.4.1.2.
PlainCdr2
XCDR2 without a header. XTypes 1.3 §7.4.2.
DelimitedCdr
XCDR2 with a delimiter header, for @appendable.
PlCdr2
XCDR2 with a parameter list, for @mutable.
Implementations§
Source§impl Encoding
impl Encoding
Sourcepub const fn max_alignment(self) -> u8
pub const fn max_alignment(self) -> u8
The largest alignment any primitive takes.
XTypes 1.3 §7.4.1, the XCDR stream operations table, defines it outright:
MAXALIGN( VERSION2) = 4MAXALIGN( VERSION1) = 8MAXALIGN( VERSION_NONE) = 8
and ALIGN(N) aligns to MIN(N, XCDR.maxalign). §7.6.8 repeats
it for the key holder: “the maximum alignment in PLAIN_CDR2
(i.e., 4)”.
§Why this reads as a correction
It was briefly eight for both versions, on the authority of a
wire vector V-3 in crates/cdr/tests/xcdr2_wire_vectors.rs at
e1f3af895. That vector is not an OMG artefact — its header
cites §7.4.2 but its byte table was computed by hand, and it pads
the trailing double to align(8) for a total of 48 bytes. Three
independent sources say 44:
- the spec text above,
- Cyclone DDS,
src/core/cdr/src/dds_cdrstream.c:239—xcdr_version == DDSI_RTPS_CDR_ENC_VERSION_2 ? MK_ALIGN(4) : MK_ALIGN(8), and:2435.alignmask = (… ? 3 : 7), - Fast CDR,
src/cpp/Cdr.cpp:238—align64_ = 4on reading an XCDRv2 encapsulation, 8 otherwise.
Measured, not read: @final struct Point { long x; double y; }
with x=1, y=2.0 comes off Cyclone’s and RTI Connext 7.7’s own
serialisers as twelve payload bytes,
010000000000000000000040, with the double at offset 4.
tests/fixtures/vendor_bytes.md records the runs.