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 hexadecimals 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.
To create a new random (V4) UUID and print it out in hexadecimal form:
extern mod extra;
use extra::uuid::Uuid;
fn main() {
let uuid1 = Uuid::new_v4();
println(uuid1.to_str());
}
Examples of string representations:
936DA01F9ABD4d9d80C702AF85C822A8
550e8400-e29b-41d4-a716-446655440000
urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4
Uuid | A Universally Unique Identifier (UUID) |
ParseError | Error details for string parsing failures |
UuidVariant | The reserved variants of UUIDs |
UuidVersion | The version of the UUID, denoting the generating algorithm |
UuidBytes | A 128-bit (16 byte) buffer containing the ID |
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).