Expand description
Checked numeric conversion helpers.
Service code often crosses database, filesystem, and API boundaries that use different integer widths and signedness. These helpers make overflow and sign-loss checks explicit while producing consistent error messages for callers.
Functionsยง
- bytes_
to_ usize - Converts a signed byte count to
usize. - calc_
total_ chunks - Calculates the number of chunks needed to cover
total_size. - f64_
seconds_ to_ u64_ millis - Converts seconds represented as
f64to rounded milliseconds. - i32_
to_ usize - Converts
i32tousize. - i64_
to_ i32 - Converts
i64toi32. - i64_
to_ u64 - Converts
i64tou64. - i64_
to_ usize - Converts
i64tousize. - non_
zero_ u32 - Converts
0toNonZeroU32::MINand preserves non-zero values. - non_
zero_ u64 - Converts
0toNonZeroU64::MINand preserves non-zero values. - u32_
to_ i32 - Converts
u32toi32. - u32_
to_ i64 - Converts
u32toi64. - u32_
to_ usize - Converts
u32tousize. - u64_
to_ i64 - Converts
u64toi64. - u64_
to_ usize - Converts
u64tousize. - u128_
to_ u64 - Converts
u128tou64. - u128_
to_ u64_ saturating - Converts
u128tou64, saturating values aboveu64::MAX. - usize_
to_ i32 - Converts
usizetoi32. - usize_
to_ i64 - Converts
usizevalues such asVec::len()or byte-slice lengths toi64. - usize_
to_ u32 - Converts
usizetou32. - usize_
to_ u64 - Converts
usizetou64.