Expand description
Canonical byte encodings of the exact numbers — the one form they cross a task boundary, the wire and storage in.
Every exact type writes its canonical name: an integer its sign and magnitude, a rational its
reduced numerator and denominator, a real algebraic number its minimal polynomial and root
index, a hyperreal its reduced numerator and denominator in dt, an infinite natural its
residue-indexed polynomials, an ordinal its Cantor normal form, a computable real its exact form
or the expression that builds it. Lengths are LEB128 varints.
A decoder trusts nothing it reads. ExactCodec::from_bytes accepts an encoding only when it
is complete, has no trailing bytes, and is the canonical encoding of the value it decodes to —
so a forged non-canonical name (an unreduced fraction, a reducible “minimal polynomial”, a
non-real exponential sum) is refused rather than breaking the equality every other part of the
system relies on. Sizes are bounded before any work is done: a minimal polynomial’s degree by
MAX_WIRE_DEGREE, collection lengths by MAX_WIRE_LEN, magnitudes by
MAX_WIRE_MAGNITUDE bytes, and nesting by MAX_WIRE_DEPTH.
Constants§
- MAX_
WIRE_ DEGREE - The largest minimal-polynomial degree a decoder accepts: an irreducibility check is a factorization, and this bound keeps a hostile encoding from demanding an expensive one.
- MAX_
WIRE_ DEPTH - The deepest nesting a decoded ordinal or expression may have.
- MAX_
WIRE_ LEN - The most elements a decoded collection may claim.
- MAX_
WIRE_ MAGNITUDE - The most magnitude bytes a decoded integer may claim.
Traits§
- Exact
Codec - A canonical, self-delimiting byte encoding. See the module documentation.
Functions§
- read_
byte - One byte.
- read_
len - A length, at most
bound. - read_
list - write_
len - write_
list - A length-prefixed list.