#uuid #unique #rand #global #random

uuid-rs

A Simple Universally Unique IDentifier (UUID)

21 releases

new 0.6.4 Nov 15, 2024
0.6.3 Apr 1, 2022
0.6.2 Jul 29, 2020
0.5.0 Jun 26, 2020
0.1.5 May 27, 2020

#577 in Algorithms

Download history 55/week @ 2024-08-04 47/week @ 2024-09-22 21/week @ 2024-09-29 90/week @ 2024-11-10

90 downloads per month

MIT license

26KB
525 lines

UUID

A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. When properly generated, UUIDs have an extremely low probability of duplication, making them ideal for distributed systems.

This crate provides a fast and compliant implementation of UUIDs based on:

Features

  • Generate UUIDs (v4 random)
  • Parse UUID strings
  • Convert UUIDs to bytes and strings
  • Zero-cost abstractions
  • No unsafe code

Usage Examples

use uuid_rs::{UUID, v4};

// Generate a random UUID
let id = v4!();
println!("{}", id); // e.g. "67e55044-10b1-426f-9247-bb680e5fe0c8"

// Parse a UUID string
let parsed = UUID::parse("67e55044-10b1-426f-9247-bb680e5fe0c8").unwrap();
assert_eq!(parsed.to_string(), "67e55044-10b1-426f-9247-bb680e5fe0c8");

// Get raw bytes
let bytes = id.as_bytes();

Security Considerations

UUIDs should not be used for security purposes or as secret tokens. While UUIDs are unique, they are not cryptographically secure identifiers. For security-sensitive applications, use purpose-built cryptographic primitives instead.

Dependencies

~0–500KB