Skip to main content

fit_wstring

Function fit_wstring 

Source
pub fn fit_wstring(
    at: usize,
    value: String,
    bound: usize,
    behaviour: TryConstruct,
) -> Result<Narrowed<String>, WireError>
Expand description

A wstring that has been read whole, against the receiver’s bound.

The bound counts UTF-16 code units, which is what wstring<N> means to every peer that has to hold the value — an N-unit buffer in all four DDS implementations’ mappings, and what XTypes 1.3 §7.4.1.1.2’s own length is in. Counting Unicode scalar values instead would accept a five-character value of six code units that no peer can hold; counting octets would make one declaration mean two different capacities under the two widths zerodds_wire::WstringUnitWidth carries.

The value arrives as a String because that is what crate::Reader::read_wstring answers and what the generated field holds; the count is over its UTF-16 encoding and not over its octets.

§Errors

As fit_string.