3232#[ doc( hidden) ]
3333pub use ambient_authority:: ambient_authority_known_at_compile_time;
3434pub use ambient_authority:: { ambient_authority, AmbientAuthority } ;
35- pub use rand:: { distributions, seq, CryptoRng , Error , Fill , Rng , RngCore , SeedableRng } ;
35+ pub use rand:: {
36+ distr, rand_core, seq, CryptoRng , Fill , Rng , RngCore , SeedableRng , TryCryptoRng , TryRngCore ,
37+ } ;
3638
3739/// Convenience re-export of common members.
3840///
3941/// This corresponds to [`rand::prelude`].
4042pub mod prelude {
41- pub use crate :: distributions :: Distribution ;
43+ pub use crate :: distr :: Distribution ;
4244 #[ cfg( feature = "small_rng" ) ]
4345 pub use crate :: rngs:: SmallRng ;
4446 pub use crate :: rngs:: { CapRng , StdRng } ;
@@ -52,7 +54,7 @@ pub mod prelude {
5254pub mod rngs {
5355 use super :: AmbientAuthority ;
5456
55- pub use rand:: rngs:: { adapter , mock , StdRng } ;
57+ pub use rand:: rngs:: StdRng ;
5658
5759 #[ cfg( feature = "small_rng" ) ]
5860 pub use rand:: rngs:: SmallRng ;
@@ -80,29 +82,26 @@ pub mod rngs {
8082 }
8183 }
8284
83- impl crate :: RngCore for OsRng {
84- #[ inline]
85- fn next_u32 ( & mut self ) -> u32 {
86- rand:: rngs:: OsRng . next_u32 ( )
87- }
85+ impl crate :: TryRngCore for OsRng {
86+ type Error = crate :: rand_core:: OsError ;
8887
8988 #[ inline]
90- fn next_u64 ( & mut self ) -> u64 {
91- rand:: rngs:: OsRng . next_u64 ( )
89+ fn try_next_u32 ( & mut self ) -> Result < u32 , Self :: Error > {
90+ rand:: rngs:: OsRng :: default ( ) . try_next_u32 ( )
9291 }
9392
9493 #[ inline]
95- fn fill_bytes ( & mut self , bytes : & mut [ u8 ] ) {
96- rand:: rngs:: OsRng . fill_bytes ( bytes )
94+ fn try_next_u64 ( & mut self ) -> Result < u64 , Self :: Error > {
95+ rand:: rngs:: OsRng :: default ( ) . try_next_u64 ( )
9796 }
9897
9998 #[ inline]
100- fn try_fill_bytes ( & mut self , bytes : & mut [ u8 ] ) -> Result < ( ) , crate :: Error > {
101- rand:: rngs:: OsRng . try_fill_bytes ( bytes)
99+ fn try_fill_bytes ( & mut self , bytes : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
100+ rand:: rngs:: OsRng :: default ( ) . try_fill_bytes ( bytes)
102101 }
103102 }
104103
105- impl crate :: CryptoRng for OsRng { }
104+ impl crate :: TryCryptoRng for OsRng { }
106105
107106 /// The type returned by `thread_rng`, essentially just a reference to a
108107 /// PRNG in memory.
@@ -142,11 +141,6 @@ pub mod rngs {
142141 fn fill_bytes ( & mut self , bytes : & mut [ u8 ] ) {
143142 self . inner . fill_bytes ( bytes)
144143 }
145-
146- #[ inline]
147- fn try_fill_bytes ( & mut self , bytes : & mut [ u8 ] ) -> Result < ( ) , crate :: Error > {
148- self . inner . try_fill_bytes ( bytes)
149- }
150144 }
151145
152146 impl crate :: CryptoRng for CapRng { }
@@ -164,23 +158,21 @@ pub mod rngs {
164158#[ inline]
165159pub fn thread_rng ( ambient_authority : AmbientAuthority ) -> rngs:: CapRng {
166160 let _ = ambient_authority;
167- rngs:: CapRng {
168- inner : rand:: thread_rng ( ) ,
169- }
161+ rngs:: CapRng { inner : rand:: rng ( ) }
170162}
171163
172164/// Retrieve the standard random number generator, seeded by the system.
173165///
174- /// This corresponds to [`rand::rngs::StdRng::from_entropy `].
166+ /// This corresponds to [`rand::rngs::StdRng::from_os_rng `].
175167///
176168/// # Ambient Authority
177169///
178170/// This function makes use of ambient authority to access the platform entropy
179171/// source.
180172#[ inline]
181- pub fn std_rng_from_entropy ( ambient_authority : AmbientAuthority ) -> rngs:: StdRng {
173+ pub fn std_rng_from_os_rng ( ambient_authority : AmbientAuthority ) -> rngs:: StdRng {
182174 let _ = ambient_authority;
183- rand:: rngs:: StdRng :: from_entropy ( )
175+ rand:: rngs:: StdRng :: from_os_rng ( )
184176}
185177
186178/// Generates a random value using the thread-local random number generator.
@@ -194,7 +186,7 @@ pub fn std_rng_from_entropy(ambient_authority: AmbientAuthority) -> rngs::StdRng
194186#[ inline]
195187pub fn random < T > ( ambient_authority : AmbientAuthority ) -> T
196188where
197- crate :: distributions :: Standard : crate :: distributions :: Distribution < T > ,
189+ crate :: distr :: StandardUniform : crate :: distr :: Distribution < T > ,
198190{
199191 let _ = ambient_authority;
200192 rand:: random ( )
0 commit comments