pub fn fit_string(
at: usize,
value: String,
bound: usize,
behaviour: TryConstruct,
) -> Result<Narrowed<String>, WireError>Expand description
A string that has been read whole, against the receiver’s bound.
The bound counts octets, which is what string<N> means to every
peer that has to hold the value: char[N + 1] in the C mapping of
all four DDS implementations, fixed_string<N> in Fast DDS’s.
Counting Unicode scalar values instead would accept a five-character
value of ten octets that no C peer can hold.
A wstring<N> bound counts UTF-16 code units instead and goes to
fit_wstring, which is a second function and not an argument: the
two bounds count different things, and one function taking “octets
or units” would be a call site deciding which by getting an
argument right.
§Errors
WireError::Discarded under TryConstruct::Discard, and
WireError::OutOfRange for a TryConstruct::Trim the front end
should have refused — Table 11 makes TRIM on a type that cannot be
trimmed “unspecified and may be treated as an error”, Cyclone refuses
such a declaration by name, and reaching here means a model that did
not come through the front end.