Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactors Timestamp, Context and ClockSequence, and adds UUIDS v6, v7, v8 #611

Merged
merged 22 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -51,12 +51,15 @@ repository = "uuid-rs/uuid"
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 @@ -79,12 +82,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 @@ -133,8 +136,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