GithubHelp home page GithubHelp logo

kennykerr / uuid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uuid-rs/uuid

0.0 1.0 0.0 1.59 MB

Generate and parse UUIDs.

Home Page: https://www.crates.io/crates/uuid

License: Other

Rust 100.00%

uuid's Introduction

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.5.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.

References


License

Licensed under either of

at your option.

FOSSA Status

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.

uuid's People

Contributors

kinggoesgaming avatar kodraus avatar bors[bot] avatar alexcrichton avatar dylan-dpc avatar rrichardson avatar redrield avatar huonw avatar veykril avatar qnnokabayashi avatar frewsxcv avatar zrzka avatar dns2utf8 avatar bors avatar brson avatar chills42 avatar pcwalton avatar steveklabnik avatar sfackler avatar mokeyish avatar brendanzab avatar kroisse avatar dependabot[bot] avatar ammgws avatar hecsalazarf avatar amadeusine avatar richo avatar nugine avatar sinistersnare avatar john-toohey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.