Skip to main content

Crate uuid

Crate uuid 

Source
Expand description

Universally Unique IDentifiers (RFC 9562). Supports generating v4 and v7 UUIDs, and parsing all versions.

UUIDs v7 support thread-local monotonic counters.

§Feature flags

FlagDescriptionDefault
stdEnables Uuid::new_v4 and Uuid::new_v7 via randYes
serdeEnables [serde] serialization/deserializationNo
sqlxEnables [sqlx] integration for PostgreSQL (type, encode, decode)No

When std is not enabled, the crate is #![no_std] compatible. Parsing, formatting, and version detection are all available.

§Example

use uuid::{Uuid, Version};

// Parse a version-4 UUID from its canonical form
let uuid = Uuid::parse("f47ac10b-58cc-4372-a567-0e02b2c3d479").unwrap();
assert_eq!(uuid.version(), Version::V4);

// Generate new UUIDs (requires `std` feature, enabled by default)
let v4 = Uuid::new_v4();
let v7 = Uuid::new_v7();
assert_eq!(v4.version(), Version::V4);
assert_eq!(v7.version(), Version::V7);

Structs§

Uuid
A 128-bit UUID (RFC 9562).

Enums§

Error
Errors that can occur when working with UUIDs.
Version
The version of a UUID (RFC 9562 §4.1).