commit | 5621405960a2718c58cf81c1f2da86d8d6580fee | [log] [tgz] |
---|---|---|
author | Andrew Walbran <qwandor@google.com> | Fri May 12 19:21:12 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri May 12 19:21:12 2023 +0000 |
tree | 5467880948c3c5fdaab582b474fb32c92d1a862c | |
parent | 6479bf1fd293055d6d2283b02c91259098e6de36 [diff] | |
parent | 9afbe0a4df5fefd414f2dbd31d97d3f628aca4aa [diff] |
Use new no-std flag to cargo2android. am: 2466fd3c4d am: 255fdd5fbb am: f09401eff5 am: 55b096d7e6 am: 9afbe0a4df Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/uuid/+/2584313 Change-Id: I7401d74d08325f10e419580acaa46f9f52026da7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
uuid
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.
Add the following to your Cargo.toml
:
[dependencies.uuid] version = "1.3.0" features = [ "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::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.
The minimum supported Rust version for uuid
is documented in CI. It may be bumped in minor releases as necessary.
uuid
library docs.Licensed under either of
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.