Archive of https://github.com/uuid-rs/uuid — Generate and parse UUIDs. https://www.crates.io/crates/uuid
  • Rust 99.8%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ashley Mannix 276c23628a
Merge pull request #918 from uuid-rs/cargo/v1.28.0
Prepare for 1.28.0 release
2026-10-10 10:01:20 +10:00
.cargo update rust toolchain before building 2025-01-10 11:52:37 +10:00
.github/workflows bump MSRV to 1.89.0 2026-09-30 06:59:46 +05:30
benches don't panic in overflowing Timestamp to SystemTime conversion 2026-09-10 09:49:43 +10:00
examples note that ordering applies to fields in to/from_bytes_le 2026-01-24 20:32:15 +10:00
fuzz fix up name of fuzz script in readme 2026-06-09 19:37:27 +10:00
rng prepare for 1.28.0 release 2026-10-10 09:45:49 +10:00
src prepare for 1.28.0 release 2026-10-10 09:45:49 +10:00
tests Accept case-insensitive urn:uuid: prefixes when parsing 2026-09-16 14:38:53 +05:30
.gitignore ignore vim files 2019-03-01 01:14:27 -08:00
Cargo.toml prepare for 1.28.0 release 2026-10-10 09:45:49 +10:00
CODE_OF_CONDUCT.md update contact details in the CoC 2022-03-14 12:09:12 +10:00
CONTRIBUTING.md Fix broken link to RFC 1574 in CONTRIBUTING.md 2024-12-27 17:07:44 +02:00
COPYRIGHT Add COPYRIGHT file and add license headers to all rs files 2018-05-11 16:51:06 -07:00
LICENSE-APACHE Organise code and add Travis CI config 2014-07-30 23:14:56 +01:00
LICENSE-MIT copyright added to licence 2018-02-16 17:06:17 +05:30
README.md prepare for 1.28.0 release 2026-10-10 09:45:49 +10:00
SECURITY.md Create SECURITY.md 2023-04-13 08:40:30 +10:00

uuid

Latest Version Continuous integration

Here's an example of a UUID:

67e55044-10b1-426f-9247-bb680e5fe0c8

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.

Getting started

Add the following to your Cargo.toml:

[dependencies.uuid]
version = "1.28.0"
# Lets you generate random UUIDs
features = [
    "v4",
]

When you want a UUID, you can generate one:

use uuid::Uuid;

let id = Uuid::new_v4();

If you have a UUID value, you can use its string literal form inline:

use uuid::{uuid, Uuid};

const ID: Uuid = uuid!("67e55044-10b1-426f-9247-bb680e5fe0c8");

You can also parse UUIDs without needing any crate features:

use uuid::{Uuid, Version};

let my_uuid = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8")?;

assert_eq!(Some(Version::Random), my_uuid.get_version());

If you'd like to parse UUIDs really fast, check out the uuid-simd library.

For more details on using uuid, see the library documentation.

References


License

Licensed under either of

at your option.

Contribution

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.