The short answer is, "you don't." The SystemTime
type doesn't implement any methods for converting into any integer types. There are probably good reasons for this. For example, there's no reason for the time to even be representable by an integer type. What if the current time is not a whole number of seconds since whatever reference is used?
If you really need an integer type out of this, you could compute the time elapsed since some defined reference, like the Unix epoch. This will yield a Duration
, which does implement conversions to numeric types.
Another option might be to hash this time, possibly along with the salt from your RNG. The SystemTime
does impl Hash
, so you can feed the time and your random number, and generate a u64
as your ID.