uuid

Latest Version Join the chat at https://gitter.im/uuid-rs/Lobby Minimum rustc version Build Status Build Status Average time to resolve an issue Percentage of issues still open


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.

Dependencies

By default, this crate depends on nothing but std and cannot generate [Uuid]s. You need to enable the following Cargo features to enable various pieces of functionality:

You need to enable one of the following Cargo features together with v3, v4 or v5 feature if you're targeting wasm32 architecture:

By default, uuid can be depended on with:

toml [dependencies] uuid = "0.8"

To activate various features, use syntax like:

toml [dependencies] uuid = { version = "0.8", features = ["serde", "v4"] }

You can disable default features with:

toml [dependencies] uuid = { version = "0.8", default-features = false }

Examples

To parse a UUID given in the simple format and print it as a urn:

```rust use uuid::Uuid;

fn main() { let myuuid = Uuid::parsestr("936DA01F9ABD4d9d80C702AF85C822A8").unwrap(); println!("{}", myuuid.tourn()); } ```

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

``rust // Note that this requires thev4` feature enabled in the uuid crate.

use uuid::Uuid;

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

Strings

Examples of string representations:

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.