Crate uuid [] [src]

Generate and parse UUIDs

Provides support for Universally Unique Identifiers (UUIDs). A UUID is a unique 128-bit number, stored as 16 octets. UUIDs are used to assign unique identifiers to entities without requiring a central allocating authority.

They are particularly useful in distributed systems, though can be used in disparate areas, such as databases and network protocols. Typically a UUID is displayed in a readable string form as a sequence of hexadecimal digits, separated into groups by hyphens.

The uniqueness property is not strictly guaranteed, however for all practical purposes, it can be assumed that an unintentional collision would be extremely unlikely.

Examples

To create a new random (V4) UUID and print it out in hexadecimal form:

use uuid::Uuid;

fn main() {
    let my_uuid = Uuid::new_v4();
    println!("{}", my_uuid);
}

To parse parse a UUID in the simple format and print it as a urn:

use uuid::Uuid;

fn main() {
    let my_uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap();
    println!("{}", my_uuid.to_urn_string());
}

Strings

Examples of string representations:

References

Structs

Uuid

A Universally Unique Identifier (UUID)

Enums

ParseError

Error details for string parsing failures

UuidVariant

The reserved variants of UUIDs

UuidVersion

The version of the UUID, denoting the generating algorithm

Type Definitions

UuidBytes

A 128-bit (16 byte) buffer containing the ID