Function uuid7::uuid7

source ·
pub fn uuid7() -> Uuid
Available on crate feature global_gen only.
Expand description

Generates a UUIDv7 object.

This function employs a global generator and guarantees the process-wide monotonic order of UUIDs generated within the same millisecond. On Unix, this function resets the generator when the process ID changes (i.e., upon process forks) to prevent collisions across processes.

Examples

let uuid = uuid7::uuid7();
println!("{}", uuid); // e.g., "01809424-3e59-7c05-9219-566f82fff672"
println!("{:?}", uuid.as_bytes()); // as 16-byte big-endian array

let uuid_string: String = uuid7::uuid7().to_string();