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
| Flag | Description | Default |
|---|---|---|
std | Enables Uuid::new_v4 and Uuid::new_v7 via rand | Yes |
serde | Enables [serde] serialization/deserialization | No |
sqlx | Enables [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).