Skip to content

Commit

Permalink
Merge pull request #611 from rrichardson/six-seven-eight
Browse files Browse the repository at this point in the history
refactors Timestamp, Context and ClockSequence, and adds UUIDS v6, v7, v8
  • Loading branch information
KodrAus authored Sep 1, 2022
2 parents e765781 + 954e279 commit b6d892b
Show file tree
Hide file tree
Showing 12 changed files with 799 additions and 263 deletions.
90 changes: 76 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Continuous integration

env:
VERSION_FEATURES: "v1 v3 v4 v5 v6 v7"
STABLE_DEP_FEATURES: "serde arbitrary"

on:
pull_request:
push:
Expand Down Expand Up @@ -34,13 +38,12 @@ jobs:
- nightly
os:
- macos-10.15
- windows-2019
- ubuntu-20.04
rust_target:
rust_target:
- x86_64-gnu
- x86_64-msvc
- x86_64-apple-darwin

steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -61,8 +64,11 @@ jobs:
- name: Examples
run: cargo test --all-features --examples

- name: Powerset
run: cargo hack test --feature-powerset --lib --optional-deps "serde arbitrary" --depth 3
- name: Each version feature
run: cargo hack test --lib --each-feature --optional-deps $STABLE_DEP_FEATURES

- name: All version features
run: cargo hack test --lib --each-feature --features "$VERSION_FEATURES" --optional-deps "$STABLE_DEP_FEATURES"

msrv:
name: "Tests / MSRV / OS: ${{ matrix.os }}"
Expand All @@ -71,7 +77,6 @@ jobs:
matrix:
os:
- macos-10.15
- windows-2019
- ubuntu-20.04

steps:
Expand All @@ -86,7 +91,7 @@ jobs:
override: true

- name: Version features
run: cargo test --features "v1 v3 v4 v5 serde"
run: cargo test --features "$VERSION_FEATURES $STABLE_DEP_FEATURES"

wasm:
name: Tests / WebAssembly
Expand All @@ -102,18 +107,17 @@ jobs:
run: wasm-pack test --node

- name: Version features
run: wasm-pack test --node -- --features "js v1 v3 v4 v5"
run: wasm-pack test --node -- --features "$VERION_FEATURES $STABLE_DEP_FEATURES js"

- name: Fast RNG
run: wasm-pack test --node -- --features "js v4 fast-rng"

mips:
name: Tests / MIPS (Big Endian)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -147,12 +151,11 @@ jobs:
with:
command: build
args: -Z avoid-dev-deps --target thumbv6m-none-eabi --no-default-features

- name: Version features
uses: actions-rs/cargo@v1
with:
command: build
args: -Z avoid-dev-deps --target thumbv6m-none-eabi --no-default-features --features "v1 v3 v5 serde"
args: -Z avoid-dev-deps --target thumbv6m-none-eabi --no-default-features --features "v1 v3 v5 v6 serde"

nodeps:
name: Build / No deps
Expand All @@ -174,4 +177,63 @@ jobs:
run: cargo install cargo-hack

- name: Powerset
run: cargo hack check --feature-powerset -Z avoid-dev-deps
run: cargo hack check --each-feature -Z avoid-dev-deps
win_tests:
name: "Tests / OS: Windows 2019 - ${{ matrix.channel }}-${{ matrix.rust_target }}"
runs-on: windows-2019
env:
RUSTFLAGS: "--cfg uuid_unstable"
RUSTDOCFLAGS: "--cfg uuid_unstable"
strategy:
matrix:
channel:
- stable
- beta
- nightly
os:
- windows-2019
rust_target:
- x86_64-gnu
- x86_64-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ matrix.channel }}-${{ matrix.rust_target }}

- name: Install cargo-hack
run: cargo install cargo-hack

- name: Docs
run: cargo test --all-features --doc

- name: Examples
run: cargo test --all-features --examples

- name: Each version feature
run: cargo hack test --lib --each-feature --optional-deps $env:STABLE_DEP_FEATURES

- name: All version features
run: cargo hack test --lib --each-feature --features "$env:VERSION_FEATURES" --optional-deps "$env:STABLE_DEP_FEATURES"

win-msrv:
name: "Tests / MSRV / OS: Windows 2019"
runs-on: windows-2019
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.57.0
override: true

- name: Version features
run: cargo test --features "$env:VERSION_FEATURES $env:STABLE_DEP_FEATURES"
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ status = "actively-developed"
default = ["std"]
std = []
macro-diagnostics = ["private_uuid-macro-internal"]

# NOTE: When adding new features, check the `ci.yml` workflow ..
# and include them where necessary (you can follow along with existing features)
v1 = ["private_atomic"]
v3 = ["md5"]
v4 = ["rng"]
v5 = ["sha1"]

v6 = ["private_atomic"]
v7 = ["rng"]
v8 = []
js = ["private_getrandom", "private_getrandom/js"]

rng = ["private_getrandom"]
Expand All @@ -76,12 +79,12 @@ version = "2"
# Public: Used in trait impls on `Uuid`
[dependencies.arbitrary]
optional = true
version = "1"
version = "=1.1.3"

# Public (unstable): Used in `zerocopy` derive
# Unstable: also need RUSTFLAGS="--cfg uuid_unstable" to work
# This feature may break between releases, or be removed entirely before
# stabilization.
# stabilization.
# See: https://github.com/uuid-rs/uuid/issues/588
[dependencies.zerocopy]
optional = true
Expand Down Expand Up @@ -130,8 +133,6 @@ version = "1.1.2"
path = "macros"
optional = true

# Private
# Don't depend on this optional feature directly: it may change at any time
[dependencies.private_atomic]
package = "atomic"
default-features = false
Expand Down
40 changes: 32 additions & 8 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ impl Uuid {
Uuid::from_bytes([0; 16])
}

/// The 'max UUID'.
///
/// The max UUID is a special form of UUID that is specified to have all
/// 128 bits set to one, as defined in [IETF RFC 4122 Update Section 5.4][Draft RFC].
///
/// [Draft RFC]: https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04#page-12
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// # use uuid::Uuid;
/// let uuid = Uuid::max();
///
/// assert_eq!(
/// "ffffffff-ffff-ffff-ffff-ffffffffffff",
/// uuid.hyphenated().to_string(),
/// );
/// ```
pub const fn max() -> Self {
Uuid::from_bytes([0xFF; 16])
}

/// Creates a UUID from four field values.
///
/// # Examples
Expand Down Expand Up @@ -283,7 +307,7 @@ impl Uuid {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -324,7 +348,7 @@ impl Uuid {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -359,7 +383,7 @@ impl Uuid {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -390,7 +414,7 @@ impl Uuid {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -422,7 +446,7 @@ impl Uuid {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -491,7 +515,7 @@ impl Builder {
/// Basic usage:
///
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// # use uuid::{Builder, Uuid};
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
Expand Down Expand Up @@ -565,7 +589,7 @@ impl Builder {
///
/// ```
/// # use uuid::Builder;
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
/// 0xb1, 0xb2,
Expand Down Expand Up @@ -600,7 +624,7 @@ impl Builder {
///
/// ```
/// # use uuid::Builder;
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # fn main() -> Result<(), uuid::Error> {
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
/// 0xb1, 0xb2,
Expand Down
Loading

0 comments on commit b6d892b

Please sign in to comment.