gecko-dev/third_party/rust/uuid
Kartikaya Gupta 47c3dd535d Bug 1369156 - Re-vendor third-party rust libraries with latest cargo-vendor. r=froydnj
MozReview-Commit-ID: LQicTh0fmk0

--HG--
extra : rebase_source : 7a5ee9c3242fefa72e8d0372b8e9c03170c7df4b
2017-06-20 16:05:17 -04:00
..
benches Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
src Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
.cargo-checksum.json Bug 1369156 - Re-vendor third-party rust libraries with latest cargo-vendor. r=froydnj 2017-06-20 16:05:17 -04:00
.cargo-ok Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
.travis.yml Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
Cargo.toml Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
LICENSE-APACHE Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
LICENSE-MIT Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00
README.md Bug 1340637 - Vendor geckodriver dependencies; r=ted 2017-05-23 18:03:07 +01:00

README.md

uuid

Build Status

A Rust library to generate and parse UUIDs.

Provides support for Universally Unique Identifiers (UUIDs). A UUID is a unique 128-bit number, stored as 16 octets. 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.

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]

uuid = "0.1"

and this to your crate root:

extern crate uuid;

Examples

To create a new random (V4) UUID and print it out in hexadecimal form:

use uuid::Uuid;

fn main() {
    let my_uuid = Uuid::new_v4();
    println!("{}", my_uuid);
}

The library supports 5 versions of UUID:

Name Version
Mac Version 1: MAC address
Dce Version 2: DCE Security
Md5 Version 3: MD5 hash
Random Version 4: Random
Sha1 Version 5: SHA-1 hash

To parse a simple UUID, then print the version and urn string format:

use uuid::Uuid;

fn main() {
    let my_uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap();
    println!("Parsed a version {} UUID.", my_uuid.get_version_num());
    println!("{}", my_uuid.to_urn_string());
}

References

Wikipedia: Universally Unique Identifier