Skip to content

Commit

Permalink
fix up feature selection
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Feb 4, 2025
1 parent 406fb23 commit 1ed9390
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ v8 = []
js = ["dep:wasm-bindgen"]

rng = ["dep:getrandom"]
rng-getrandom = ["rng", "dep:uuid-getrandom-internal"]
rng-rand = ["rng-getrandom", "dep:rand"]
rng-getrandom = ["rng", "dep:getrandom", "dep:uuid-rng-internal", "uuid-rng-internal/getrandom"]
rng-rand = ["rng", "dep:rand", "dep:uuid-rng-internal", "uuid-rng-internal/rand"]

fast-rng = ["rng", "dep:rand"]

Expand Down Expand Up @@ -132,9 +132,9 @@ default-features = false
version = "0.3"
optional = true

[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dependencies.uuid-getrandom-internal]
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dependencies.uuid-rng-internal]
version = "1.12.1"
path = "getrandom"
path = "rng"
optional = true

# Private
Expand Down Expand Up @@ -198,7 +198,7 @@ version = "1"
[workspace]
members = [
"macros",
"getrandom",
"rng",
"examples",
"tests/smoke-test",
"tests/wasm32-getrandom-test",
Expand Down
7 changes: 6 additions & 1 deletion getrandom/Cargo.toml → rng/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "uuid-getrandom-internal"
name = "uuid-rng-internal"
version = "1.12.1"
edition = "2018"
authors = [
Expand All @@ -19,3 +19,8 @@ license = "Apache-2.0 OR MIT"
# Forces a dependency on `getrandom`
[dependencies.getrandom]
version = "0.3"
optional = true

[dependencies.rand]
version = "0.9"
optional = true
6 changes: 5 additions & 1 deletion getrandom/src/lib.rs → rng/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
#[doc(hidden)]
pub mod __private {
pub use getrandom::*;
#[cfg(feature = "getrandom")]
pub use getrandom;

#[cfg(feature = "rand")]
pub use rand;
}
12 changes: 6 additions & 6 deletions src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ mod imp {
#[cfg(feature = "rng-rand")]
impl Rng for RngImp {
fn u128() -> u128 {
rand::random()
uuid_rng_internal::__private::rand::random()
}

fn u64() -> u64 {
rand::random()
uuid_rng_internal::__private::rand::random()
}

fn u16() -> u16 {
rand::random()
uuid_rng_internal::__private::rand::random()
}
}

Expand All @@ -136,7 +136,7 @@ mod imp {
fn u128() -> u128 {
let mut bytes = [0u8; 16];

uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
// NB: getrandom::Error has no source; this is adequate display
panic!("could not retrieve random bytes for uuid: {}", err)
});
Expand All @@ -147,7 +147,7 @@ mod imp {
fn u64() -> u64 {
let mut bytes = [0u8; 8];

uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
// NB: getrandom::Error has no source; this is adequate display
panic!("could not retrieve random bytes for uuid: {}", err)
});
Expand All @@ -158,7 +158,7 @@ mod imp {
fn u16() -> u16 {
let mut bytes = [0u8; 2];

uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
// NB: getrandom::Error has no source; this is adequate display
panic!("could not retrieve random bytes for uuid: {}", err)
});
Expand Down

0 comments on commit 1ed9390

Please sign in to comment.