Skip to main content

as_u64

Function as_u64 

Source
pub(crate) fn as_u64(value: &Value) -> Option<u64>
Expand description

Read an unsigned integer, accepting the float form CBOR also permits.

An encoder may write an integral value as a float, and one of the two implementations of this format does exactly that for anything past 32 bits — which every epoch-millisecond timestamp is. Reading only major type 0 here meant startTime went missing from every trace that encoder wrote, and the file was rejected before a single event was read.

A float carries integers exactly only up to 2^53, so one that is fractional or beyond that range is not an integer this can honour, and is refused rather than rounded.