Skip to main content

parse_fixed

Function parse_fixed 

Source
pub fn parse_fixed(
    text: &str,
    digits: u8,
    scale: u8,
    at: usize,
) -> Result<FixedParts<'_>, WireError>
Expand description

Split a fixed<P, S> value, refusing everything the declaration cannot carry.

The one place the rule for a legal fixed value lives. Three call sites had a copy of it before — this writer, zerodds-wire-codec’s encoder and its canonical form — and a copy that disagreed with the others would accept a value one path writes and another rejects, on the same sample.

What it refuses, and why each is a refusal and not a silent repair:

  • A declaration outside IDL 4.2 rule (42): P of zero carries no digit to pair the sign nibble with, P above 31 has no packing defined, and an S wider than P describes a fraction with no type to hold it.
  • A value that is not a decimal, or has no digits at all.
  • An integer part wider than P - S, or a fraction wider than S. A truncated decimal is the wrong number with nothing to notice it by, which is the failure fixed exists to prevent.