Skip to main content

WstringLengthPolicy

Struct WstringLengthPolicy 

Source
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:

implementationC1 countsC2 terminatorC3 unit
Cyclone, OpenDDS, RTI XCDR2, omniORB, JacORBoctetsabsent2
Fast DDScharactersabsent2
RTI, XCDR1characterspresent4
TAOoctetsabsent4
ros-cyclone, ros-fastrtpscharactersabsent4

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: WstringLengthCounts

C1 — what the length prefix counts.

§terminator: WstringTerminator

C2 — whether a terminating NUL is written and counted.

§unit: WstringUnitWidth

C3 — how wide one code unit is.

Implementations§

Source§

impl WstringLengthPolicy

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn is_default(self) -> bool

Whether this is the default cell, Self::SPECIFICATION.

Source

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.

Source

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.

Source

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.

Source

pub const fn terminator_at(self, _position: WirePosition) -> WstringTerminator

C2 at a position — whether a terminating NUL is written.

Source

pub const fn unit_at(self, _position: WirePosition) -> WstringUnitWidth

C3 at a position — how wide one code unit is.

Source

pub const fn character_width(self, position: WirePosition) -> usize

How many octets one code unit takes at a position.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for WstringLengthPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WstringLengthPolicy

Source§

impl Debug for WstringLengthPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WstringLengthPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for WstringLengthPolicy

Source§

impl Hash for WstringLengthPolicy

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for WstringLengthPolicy

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for WstringLengthPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for WstringLengthPolicy

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for WstringLengthPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.