Function spinoso_securerandom::uuid

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

Generate a version 4 UUID and return a String.

A version 4 UUID is randomly generated. See RFC 4122 for details.


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


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

If an allocation error occurs, an error is returned.