diff --git a/Cargo.toml b/Cargo.toml index 2412fee..cda368c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] @@ -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 @@ -198,7 +198,7 @@ version = "1" [workspace] members = [ "macros", - "getrandom", + "rng", "examples", "tests/smoke-test", "tests/wasm32-getrandom-test", diff --git a/getrandom/Cargo.toml b/rng/Cargo.toml similarity index 82% rename from getrandom/Cargo.toml rename to rng/Cargo.toml index 41c8979..ec3b384 100644 --- a/getrandom/Cargo.toml +++ b/rng/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "uuid-getrandom-internal" +name = "uuid-rng-internal" version = "1.12.1" edition = "2018" authors = [ @@ -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 diff --git a/getrandom/src/lib.rs b/rng/src/lib.rs similarity index 77% rename from getrandom/src/lib.rs rename to rng/src/lib.rs index 01727bb..7b0b22e 100644 --- a/getrandom/src/lib.rs +++ b/rng/src/lib.rs @@ -12,5 +12,9 @@ #[doc(hidden)] pub mod __private { - pub use getrandom::*; + #[cfg(feature = "getrandom")] + pub use getrandom; + + #[cfg(feature = "rand")] + pub use rand; } diff --git a/src/rng.rs b/src/rng.rs index 5b5403b..6236446 100644 --- a/src/rng.rs +++ b/src/rng.rs @@ -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() } } @@ -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) }); @@ -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) }); @@ -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) });