75 releases (28 stable)

new 1.13.2 Feb 17, 2025
1.12.1 Jan 21, 2025
1.11.0 Oct 16, 2024
1.10.0 Jul 9, 2024
0.1.0 Nov 27, 2014

#2 in Parser implementations

Download history 2305390/week @ 2024-10-29 2300843/week @ 2024-11-05 2453170/week @ 2024-11-12 2334849/week @ 2024-11-19 1918428/week @ 2024-11-26 2303218/week @ 2024-12-03 2648509/week @ 2024-12-10 2095369/week @ 2024-12-17 1021786/week @ 2024-12-24 1435617/week @ 2024-12-31 2547228/week @ 2025-01-07 2557856/week @ 2025-01-14 2539430/week @ 2025-01-21 2557828/week @ 2025-01-28 2929128/week @ 2025-02-04 2413731/week @ 2025-02-11

10,786,434 downloads per month
Used in 16,282 crates (5,472 directly)

Apache-2.0 OR MIT

260KB
4.5K SLoC

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.13.2"
features = [
    "v4",                # Lets you generate random UUIDs
]

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.

Dependencies

~0–5.5MB
~21K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy