1# `uuid` 2 3[](https://crates.io/crates/uuid) 4 5[](https://github.com/uuid-rs/uuid/actions/workflows/ci.yml) 6 7Here's an example of a UUID: 8 9```text 1067e55044-10b1-426f-9247-bb680e5fe0c8 11``` 12 13A UUID is a unique 128-bit value, stored as 16 octets, and regularly 14formatted as a hex string in five groups. UUIDs are used to assign unique 15identifiers to entities without requiring a central allocating authority. 16 17They are particularly useful in distributed systems, though can be used in 18disparate areas, such as databases and network protocols. Typically a UUID 19is displayed in a readable string form as a sequence of hexadecimal digits, 20separated into groups by hyphens. 21 22The uniqueness property is not strictly guaranteed, however for all 23practical purposes, it can be assumed that an unintentional collision would 24be extremely unlikely. 25 26## Getting started 27 28Add the following to your `Cargo.toml`: 29 30```toml 31[dependencies.uuid] 32version = "1.3.0" 33features = [ 34 "v4", # Lets you generate random UUIDs 35 "fast-rng", # Use a faster (but still sufficiently random) RNG 36 "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs 37] 38``` 39 40When you want a UUID, you can generate one: 41 42```rust 43use uuid::Uuid; 44 45let id = Uuid::new_v4(); 46``` 47 48If you have a UUID value, you can use its string literal form inline: 49 50```rust 51use uuid::{uuid, Uuid}; 52 53const ID: Uuid = uuid!("67e55044-10b1-426f-9247-bb680e5fe0c8"); 54``` 55 56You can also parse UUIDs without needing any crate features: 57 58```rust 59use uuid::{Uuid, Version}; 60 61let my_uuid = Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8")?; 62 63assert_eq!(Some(Version::Random), my_uuid.get_version()); 64``` 65 66If you'd like to parse UUIDs _really_ fast, check out the [`uuid-simd`](https://github.com/nugine/uuid-simd) 67library. 68 69For more details on using `uuid`, [see the library documentation](https://docs.rs/uuid/1.3.0/uuid). 70 71## Minimum Supported Rust Version (MSRV) 72 73The minimum supported Rust version for `uuid` is documented in 74CI. It may be bumped in minor releases as necessary. 75 76## References 77 78* [`uuid` library docs](https://docs.rs/uuid/1.3.0/uuid). 79* [Wikipedia: Universally Unique Identifier](http://en.wikipedia.org/wiki/Universally_unique_identifier). 80* [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace](http://tools.ietf.org/html/rfc4122). 81 82--- 83# License 84 85Licensed under either of 86 87* Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0) 88* MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT) 89 90at your option. 91 92 93[](https://app.fossa.com/projects/git%2Bgithub.com%2Fuuid-rs%2Fuuid?ref=badge_large) 94 95## Contribution 96 97Unless you explicitly state otherwise, any contribution intentionally submitted 98for inclusion in the work by you, as defined in the Apache-2.0 license, shall 99be dual licensed as above, without any additional terms or conditions.