diff --git a/Cargo.lock b/Cargo.lock index 42e9aea5a..bb36f46f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1024,9 +1024,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.17.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ "getrandom", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 07edc1582..e0d288d38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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)'] } diff --git a/Justfile b/Justfile index 5187b4307..5a91ee78f 100644 --- a/Justfile +++ b/Justfile @@ -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: diff --git a/crates/newtype-uuid-macros/Cargo.toml b/crates/newtype-uuid-macros/Cargo.toml index d7583c5ba..cda4757df 100644 --- a/crates/newtype-uuid-macros/Cargo.toml +++ b/crates/newtype-uuid-macros/Cargo.toml @@ -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 diff --git a/crates/newtype-uuid/Cargo.toml b/crates/newtype-uuid/Cargo.toml index 21d24539d..bece0c531 100644 --- a/crates/newtype-uuid/Cargo.toml +++ b/crates/newtype-uuid/Cargo.toml @@ -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"] diff --git a/crates/newtype-uuid/src/lib.rs b/crates/newtype-uuid/src/lib.rs index 4a94dd3d2..6c8f5d24e 100644 --- a/crates/newtype-uuid/src/lib.rs +++ b/crates/newtype-uuid/src/lib.rs @@ -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. @@ -302,6 +304,14 @@ impl TypedUuid { 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.