Skip to main content

Crate mynd_math

Crate mynd_math 

Source
Expand description

Checked integer arithmetic for Mynd’s untrusted image-data boundaries.

The crate provides constant-work, allocation-free primitives for integer conversion, addition, multiplication, alignment, and bounded ranges. Every failure is explicit; no operation wraps, saturates, truncates, or panics.

Enums§

ArithmeticOperation
The checked operation that could not be represented by its output type.
MathError
A failure from a checked Mynd arithmetic primitive.

Functions§

checked_add_u64
Adds two u64 values without wrapping or saturating.
checked_add_usize
Adds two usize values without wrapping or saturating.
checked_align_up_u64
Rounds value upward to a multiple of alignment in u64 arithmetic.
checked_align_up_usize
Rounds value upward to a multiple of alignment in usize arithmetic.
checked_i64_to_u64
Converts a nonnegative i64 value to u64.
checked_i64_to_usize
Converts a nonnegative i64 value to usize without truncation.
checked_mul_u64
Multiplies two u64 values without wrapping or saturating.
checked_mul_usize
Multiplies two usize values without wrapping or saturating.
checked_range_u64
Constructs a half-open u64 range contained by an exclusive upper bound.
checked_range_usize
Constructs a half-open usize range contained by an exclusive upper bound.
checked_u64_to_i64
Converts u64 to i64 without truncation or sign change.
checked_u64_to_u32
Converts u64 to u32 without truncation.
checked_u64_to_usize
Converts u64 to usize without truncation.
checked_usize_to_u64
Converts usize to u64 without truncation.

Type Aliases§

MathResult
The result type returned by checked Mynd arithmetic primitives.