mynd-math
Support crate for mynd: small, audited,
format-neutral arithmetic primitives used before untrusted image values become
offsets, lengths, ranges, or platform-sized indexes.
Most applications should depend on the facade crate:
[]
= { = "0.3.0", = false }
Expert users can depend directly on mynd-math:
[]
= { = "0.1.0", = false }
Capability
- checked signed, fixed-width, and platform-width integer conversions;
- checked
u64andusizeaddition and multiplication; - checked upward alignment for any nonzero multiple;
- checked half-open ranges against an exclusive upper bound;
- structured, allocation-free errors identifying conversion, overflow, alignment, and range failures.
Operations never wrap, saturate, silently truncate, allocate, inspect external state, or use unsafe code. Alignment does not imply a power-of-two memory-layout guarantee. Range functions accept an empty range at the exclusive upper bound.
Verification
The crate is covered by extrema matrices, exhaustive reduced-domain tests, cross-operation consistency tests, all supported Rust and platform targets, and Kani proofs over full-width and explicitly bounded domains. See the arithmetic contract for exact invariants and evidence mapping.
Compatibility
The supported MSRV is Rust 1.90.0. Rust 1.90.0 through 1.97.1 are covered by the workspace compatibility matrix, with 1.97.1 used for development and release verification.
License
Licensed under either Apache-2.0 or MIT, at your option.