Function spinoso_securerandom::uuid

source ·
pub fn uuid() -> Result<String, Error>
Expand description

Generate a Version 4 (random) UUID and return a String.

A Version 4 UUID is randomly generated. See RFC4122 for details.

§Examples

let uuid = spinoso_securerandom::uuid()?;
assert_eq!(uuid.len(), 36);
assert!(uuid.chars().all(|ch| ch == '-' || ch.is_ascii_hexdigit()));

§Errors

If the underlying source of randomness returns an error, an error is returned.

If an allocation error occurs, an error is returned.