pub enum MapLengthPolicy {
SequenceEquivalent,
Rule15Omits,
}Expand description
Whether a delimited map carries an entry count.
This policy exists because XTypes 1.3 contradicts itself, not
because two implementations were measured disagreeing. Nothing in
crates/ast-layout/tests/fixtures/vendor_bytes.md has a map in it,
so neither shape below is verified against a vendor.
§7.4.1.1.4 defines a map by an equivalence: it “shall be serialized
as if” it were sequence<MapEntry_<key_type>_<value_type>>. A
sequence under XCDR2 is rule (12) of §7.4.3.5.3, DHEADER then
O.length then the elements. So the equivalence yields both words.
Rule (15) of the same clause, which is the rule written for
MAP_TYPE itself under XCDR2, writes DHEADER and then the pairs —
with no O.length. Rules (14) and (16), the primitive-map and the
XCDR1 cases, both write O.length and no delimiter, so the omission
is only in (15).
The two readings differ by four bytes. Both are decodable — with a delimiter a reader can consume entries until the byte extent is used — which is why neither can be ruled out from the stream alone.
§Both are in the field
Measured on 2026-08-09. Neither C generator parses map, so the
implementations that can be asked are eProsima Fast DDS and OpenDDS
3.34.0, and they took one reading each. @final struct { map<long, Cell> entries; long tail; } with one entry 5 -> {1, 2}, XCDR2
little endian: Fast DDS writes 10000000 01000000 05000000 01000000 02000000 07000000 and OpenDDS writes 0c000000 05000000 01000000 02000000 07000000. Under XCDR1, where neither delimits, the two are
identical. crates/ast-layout/tests/fixtures/vendor_bytes.md,
“Where the three cannot answer”, has the run and a second shape.
Variants§
SequenceEquivalent
Write the entry count whether or not a delimiter precedes it.
The default, because it is the reading under which §7.4.1.1.4’s equivalence holds, because it is the only one of the two that makes a map’s bytes the same shape as the sequence the clause says it is, and because it is what Fast DDS writes.
Rule15Omits
Omit the entry count when the map is delimited, as rule (15) is written.
OpenDDS’s reading: its generated operator<< calls
write_delimiter under XCDR2 and the << length in the else
branch under XCDR1, so the count and the delimiter are
alternatives rather than both.
Implementations§
Source§impl MapLengthPolicy
impl MapLengthPolicy
Sourcepub const fn is_default(self) -> bool
pub const fn is_default(self) -> bool
Whether this is the default.