pub struct WstringLengthPolicy {
pub counts: WstringLengthCounts,
pub terminator: WstringTerminator,
pub unit: WstringUnitWidth,
}Expand description
How a wstring’s length is written and how wide its code units are
— C1 × C2 × C3, a product space and not a list.
The byte-layer half of zerodds_ast_layout::WstringLengthPolicy,
which carries the measurements. Eight cells, of which five have a
name because an implementation was measured writing them:
| implementation | C1 counts | C2 terminator | C3 unit |
|---|---|---|---|
| Cyclone, OpenDDS, RTI XCDR2, omniORB, JacORB | octets | absent | 2 |
| Fast DDS | characters | absent | 2 |
| RTI, XCDR1 | characters | present | 4 |
| TAO | octets | absent | 4 |
| ros-cyclone, ros-fastrtps | characters | absent | 4 |
The other three cells are as constructible and as nameable as the five: an enumeration standing in for a product space is what left the ROS cell — characters, no terminator, four-octet units — with no name for as long as the names were the values, and two implementations writing a form this project could not express.
The order the units go out in is not here. It is
WstringUnitOrder, a fourth axis, because it crosses the length
convention rather than extending it: omniORB’s mark rides on an
octet count and nothing stops a GIOP 1.1 count from carrying one
too. Two settings that both decide one byte order, with a precedence
rule between them, is the shape that produces a wrong character and
no error.
Fields§
§counts: WstringLengthCountsC1 — what the length prefix counts.
terminator: WstringTerminatorC2 — whether a terminating NUL is written and counted.
unit: WstringUnitWidthC3 — how wide one code unit is.
Implementations§
Source§impl WstringLengthPolicy
impl WstringLengthPolicy
Sourcepub const SPECIFICATION: Self
pub const SPECIFICATION: Self
Octets, no terminator, two-octet units. XTypes 1.3 §7.4.1.1.2
and CORBA’s GIOP 1.2 wstring over a two-octet code set. The
default.
Sourcepub const CHARACTER_COUNT: Self
pub const CHARACTER_COUNT: Self
Characters, no terminator, two-octet units. Fast DDS under both versions.
Writer::write_wstring refuses a code point outside the BMP
in this cell rather than truncating it the way Fast CDR does.
Sourcepub const CHARACTER_COUNT_TERMINATED: Self
pub const CHARACTER_COUNT_TERMINATED: Self
Characters including the terminator, four-octet units. CORBA 3.3
part 2 §9.3.1.6’s GIOP 1.1 wstring, and RTI Connext 7.7
under XCDR1.
Sourcepub const SPECIFICATION_WIDE_UNITS: Self
pub const SPECIFICATION_WIDE_UNITS: Self
Octets, no terminator, four-octet units. CORBA §9.3.1.6’s GIOP
1.2 wstring over a four-octet transmission code set — TAO
2.5.24.
Sourcepub const ROS_TYPE_SUPPORT: Self
pub const ROS_TYPE_SUPPORT: Self
Characters, no terminator, four-octet units. The cell the old enumeration could not reach. Both ROS 2 type supports write it.
Sourcepub const ALL_CELLS: [Self; 8]
pub const ALL_CELLS: [Self; 8]
Every cell of C1 × C2 × C3, measured or not.
The reader sweeps this and not the measured five when it has to name the cell a refused length does fit: a cell left out of the sweep is a cell the diagnostic can never name.
Sourcepub const fn new(
counts: WstringLengthCounts,
terminator: WstringTerminator,
unit: WstringUnitWidth,
) -> Self
pub const fn new( counts: WstringLengthCounts, terminator: WstringTerminator, unit: WstringUnitWidth, ) -> Self
Build a cell of the product directly.
Public and const so that a cell nobody has named is as easy to
reach as one that is named. The named constants below are
conveniences for the cells an implementation was measured in;
they are not the set of legal values.
Sourcepub const fn is_default(self) -> bool
pub const fn is_default(self) -> bool
Whether this is the default cell, Self::SPECIFICATION.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The name a configuration uses, the same spelling
zerodds_ast_layout::WstringLengthPolicy::as_str produces.
A cell an implementation was measured in renders under the name
it shipped with; the three nobody writes render as their
coordinates, counts/terminator/width. Every one of the eight
has a name, because a value that cannot be printed cannot be
reported in a diagnostic.
Sourcepub const fn flag(self) -> &'static str
pub const fn flag(self) -> &'static str
The command-line setting that selects this cell, whole.
A &'static str and not a formatted one because
WireError::WrongFraming’s fits is a &'static str: the
point of that field is that a peer misconfiguration reports the
flag that fixes it instead of “an odd octet count”, and a field
that had to allocate would not have been there on the no-std
path.
Sourcepub const fn counts_at(self, _position: WirePosition) -> WstringLengthCounts
pub const fn counts_at(self, _position: WirePosition) -> WstringLengthCounts
C1 at a position — what the length prefix counts.
An accessor and not the field: a caller that read policy.counts
directly would have answered for every position by not asking
about any, which is exactly the shape that let a member’s wchar
framing stand in for an element’s through five emitters. The nine
implementations answer both positions alike, measured 2026-08-12,
so the argument is unused — and it is the argument that keeps
that a measurement rather than an assumption.
Sourcepub const fn terminator_at(self, _position: WirePosition) -> WstringTerminator
pub const fn terminator_at(self, _position: WirePosition) -> WstringTerminator
C2 at a position — whether a terminating NUL is written.
Sourcepub const fn unit_at(self, _position: WirePosition) -> WstringUnitWidth
pub const fn unit_at(self, _position: WirePosition) -> WstringUnitWidth
C3 at a position — how wide one code unit is.
Sourcepub const fn character_width(self, position: WirePosition) -> usize
pub const fn character_width(self, position: WirePosition) -> usize
How many octets one code unit takes at a position.
Sourcepub const fn declared_length(
self,
units: usize,
position: WirePosition,
) -> Option<u32>
pub const fn declared_length( self, units: usize, position: WirePosition, ) -> Option<u32>
The length field this cell declares for a run of units code
units, or None when it does not fit the UInt32 the field is.
The run is the whole run: the text’s units, plus C2’s terminator and C4’s mark where those are written. One expression rather than an arm per named cell, so a cell nobody has measured computes its length the same way as the five that are.
None and not a wrapped value. A length that names a prefix of
its own content is the silent class: the peer reads a well-formed
shorter wstring and then every following member from inside
this one, and nothing in the frame says so. A separate function
from Writer::write_wstring so that the refusal can be tested
at usize::MAX without a caller having to hold two gigabytes of
text to reach it.
Sourcepub const fn admits_length(self, declared: usize) -> bool
pub const fn admits_length(self, declared: usize) -> bool
Whether declared is a length this cell could have written.
Only the shape of the number, which is all a refused read has to go on: an octet count has to divide by the unit width, and a count that includes a terminator cannot be zero. A cell nobody has measured is checked by the same two rules.
A byte count and one written under
WstringUnitOrder::HostUnswapped are the same number — that
point of the order axis differs in the content’s byte order,
which no length can show — so a diagnostic that names one names
both.