pub enum MutableUnionFraming {
Specification,
BranchesFromZero,
}Expand description
How a @mutable union numbers its branches, and whether its XCDR1
parameter list is terminated.
§The clause
§7.3.1.2.1.1 numbers the members of an aggregated type sequentially
from zero, and a union’s discriminator is one of its members
(§7.2.2.4.4.4). So the discriminator takes 0 and the branches run on
from 1 — the only numbering under which the discriminator cannot
collide with an implicitly numbered branch. Rule (28) of §7.4.3.5.3
then closes an XCDR1 MUNION_TYPE with PID_SENTINEL and a length
of zero, in the same line as it does for a struct.
§What is measured
One implementation departs from both, and in the same generated
code. union-mutable
(@mutable union Choice switch (long) { case 1: long whole; default: double fraction; }, _d = 1), XCDR2 big endian:
rti 00000010 20000000 00000001 20000001 ffed2979
opendds 00000010 20000000 00000001 20000000 ffed2979and the same union under XCDR1, where the sentinel goes too:
ours 00000004 00000001 00010004 ffed2979 7f020000
opendds c0000004 00000001 c0000004 ffed2979The branch takes member id 0, which the discriminator already
has, and the list ends without PID_LIST_END. In
evolution-union-unselected the union is nested inside a struct and
what follows the missing sentinel is the enclosing long tail: a
reader walking the parameter list takes 0000002a for another
parameter header. RTI and Fast DDS both number the branch 1 and both
write the sentinel, so two implementations are with the clause and
one against it.
§One axis and not two, and the corpus says why
The two halves never occur apart in anything measured, so a second axis would have a value no recorded row reaches. They are still told apart by the rows: the four XCDR2 rows carry the numbering alone, because version 2 has no sentinel to suppress, and the four XCDR1 rows carry both. A mutation of either half is red on one of the two groups, which is what a merged axis has to be able to say before it is allowed to merge.
§It is a planner setting
Both halves reach TypeLayout — the branch’s member_id and
needs_sentinel — so it is in LayoutKey::offset_key. A cache
that left it out would serve a plan numbered from one to a caller
that asked for zero.
§No dialect selects the second value
It reproduces a defect: a parameter list with two parameters sharing
member id 0 and no terminator is not a frame a conforming reader can
walk. --union-framing branches-from-zero reaches it.
Variants§
Specification
The discriminator takes member id 0, the branches run on from 1,
and the XCDR1 parameter list closes with PID_SENTINEL.
The default, the clause, and what RTI Connext 7.7 and Fast DDS both write.
BranchesFromZero
The branches are numbered from 0, sharing member id 0 with the discriminator, and the XCDR1 parameter list closes without a sentinel.
What OpenDDS writes. Select it to reproduce an OpenDDS peer’s
@mutable union; it produces a frame no conforming reader can
walk, which is why no dialect selects it.
Implementations§
Source§impl MutableUnionFraming
impl MutableUnionFraming
Sourcepub const fn is_default(self) -> bool
pub const fn is_default(self) -> bool
Whether this is the default.
Sourcepub const fn first_branch_id(self) -> u32
pub const fn first_branch_id(self) -> u32
The member id the first branch of a @mutable union takes.
Sourcepub const fn writes_the_sentinel(self) -> bool
pub const fn writes_the_sentinel(self) -> bool
Whether a @mutable union’s XCDR1 parameter list is terminated.