Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ syn = "2.0.104"
test-strategy = "0.4.1"
trybuild = "1.0"
typify = "0.4.2"
uuid = { version = "1.17.0", default-features = false }
uuid = { version = "1.18.1", default-features = false }

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ help:
just --list

excluded_features_default := "internal-schemars08-tests internal-proptest1-tests"
excluded_features_no_std := "schemars08 serde default std alloc v4 proptest1"
excluded_features_no_std := "schemars08 serde default std alloc v4 v7 proptest1"

# Run `cargo hack --feature-powerset` on crates
powerset *args:
Expand Down
2 changes: 1 addition & 1 deletion crates/newtype-uuid-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde_tokenstream.workspace = true
syn = { workspace = true, features = ["full"] }

[dev-dependencies]
newtype-uuid = { workspace = true, features = ["v4"] }
newtype-uuid = { workspace = true, features = ["v4", "v7"] }
serde = { workspace = true, features = ["derive"] }
static_assertions.workspace = true

Expand Down
1 change: 1 addition & 0 deletions crates/newtype-uuid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ default = ["uuid/default", "std"]
std = ["alloc", "uuid/std"]
alloc = []
v4 = ["uuid/v4"]
v7 = ["uuid/v7"]
serde = ["dep:serde", "uuid/serde"]
schemars08 = ["dep:schemars", "dep:serde_json", "std"]
proptest1 = ["dep:proptest"]
Expand Down
10 changes: 10 additions & 0 deletions crates/newtype-uuid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ use core::{
marker::PhantomData,
str::FromStr,
};
#[cfg(feature = "v7")]
pub use uuid::Timestamp;
use uuid::{Uuid, Version};

/// A UUID with type-level information about what it's used for.
Expand Down Expand Up @@ -302,6 +304,14 @@ impl<T: TypedUuidKind> TypedUuid<T> {
Self::from_untyped_uuid(Uuid::new_v4())
}

/// Creates a new, random UUID v7 of this type.
#[inline]
#[cfg(feature = "v7")]
#[must_use]
pub fn new_v7(ts: uuid::Timestamp) -> Self {
Self::from_untyped_uuid(Uuid::new_v7(ts))
}

/// Returns the version number of the UUID.
///
/// This represents the algorithm used to generate the value.
Expand Down
Loading