1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// Trait for converting numeric-like values into a `u64`.
///
/// This is typically used to normalize custom duration types into milliseconds
/// for compatibility with APIs like [`core::time::Duration::from_millis`],
/// which are commonly required in async sleep contexts.
///
/// # Safety and Behavior
///
/// For types that may exceed the `u64` range (e.g., `u128`), values that cannot
/// be losslessly converted will saturate to `u64::MAX`. This avoids propagating
/// errors in time-sensitive code like ID generation. In such systems, a
/// fallback to `u64::MAX` is generally safe: it typically causes a retry
/// without compromising correctness, since most sane ID formats reserve no more
/// than 48 bits for timestamps - far below the 64-bit boundary.