u64_prefix

Function u64_prefix 

Source
pub(crate) fn u64_prefix(bytes: &[u8]) -> Result<(Option<u64>, &[u8]), Error>
Expand description

Parsed an optional u64 that is a prefix of bytes.

If no digits ([0-9]) were found at the beginning of bytes, then None is returned.

Note that this is safe to call on untrusted input. It will not attempt to consume more input than could possibly fit into a parsed integer.

Since this returns a u64, it is possible that an integer that cannot fit into an i64 is returned. Callers should handle this. (Indeed, DurationUnits handles this case.)

ยงErrors

When the parsed integer cannot fit into a u64.