Here's an example of a UUID:
A UUID is a unique 128-bit value, stored as 16 octets, and regularly formatted as a hex string in five groups. 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.
Add the following to your
 = "1.4.1" = [ "v4", # Lets you generate random UUIDs "fast-rng", # Use a faster (but still sufficiently random) RNG "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs ]
When you want a UUID, you can generate one:
use Uuid; let id = new_v4;
If you have a UUID value, you can use its string literal form inline:
use ; const ID: Uuid = uuid!;
You can also parse UUIDs without needing any crate features:
use ; let my_uuid = parse_str?; assert_eq!;
If you'd like to parse UUIDs really fast, check out the
For more details on using
uuid, see the library documentation.
Minimum Supported Rust Version (MSRV)
The minimum supported Rust version for
uuid is documented in
CI. It may be bumped in minor releases as necessary.
- Wikipedia: Universally Unique Identifier.
- RFC4122: A Universally Unique IDentifier (UUID) URN Namespace.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.