Skip to main content

parse_clamped_u64

Function parse_clamped_u64 

Source
fn parse_clamped_u64(message: &Map<String, Value>, keys: &[&str]) -> Option<u64>
Expand description

Reads a numeric field as u64, returning None when the field is missing or its value is outside [0, u64::MAX) (note the open upper bound - see the body comment). Out-of-range drops emit a debug breadcrumb so a misbehaving CLI is observable.

as u64 saturates rather than fails on out-of-range floats, so the explicit guard runs BEFORE the cast. The >= upper bound rejects u64::MAX as f64 itself (which equals 2^64, one past the largest representable u64) along with everything above.