@@ -167,6 +167,21 @@ impl<'d, T: Instance> Rng<'d, T> {
167167
168168 self . stop ( ) ;
169169 }
170+
171+ /// Generate a random u32
172+ pub fn blocking_next_u32 ( & mut self ) -> u32 {
173+ let mut bytes = [ 0 ; 4 ] ;
174+ self . blocking_fill_bytes ( & mut bytes) ;
175+ // We don't care about the endianness, so just use the native one.
176+ u32:: from_ne_bytes ( bytes)
177+ }
178+
179+ /// Generate a random u64
180+ pub fn blocking_next_u64 ( & mut self ) -> u64 {
181+ let mut bytes = [ 0 ; 8 ] ;
182+ self . blocking_fill_bytes ( & mut bytes) ;
183+ u64:: from_ne_bytes ( bytes)
184+ }
170185}
171186
172187impl < ' d , T : Instance > Drop for Rng < ' d , T > {
@@ -180,31 +195,37 @@ impl<'d, T: Instance> Drop for Rng<'d, T> {
180195 }
181196}
182197
183- impl < ' d , T : Instance > rand_core :: RngCore for Rng < ' d , T > {
198+ impl < ' d , T : Instance > rand_core_06 :: RngCore for Rng < ' d , T > {
184199 fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
185200 self . blocking_fill_bytes ( dest) ;
186201 }
187-
188202 fn next_u32 ( & mut self ) -> u32 {
189- let mut bytes = [ 0 ; 4 ] ;
190- self . blocking_fill_bytes ( & mut bytes) ;
191- // We don't care about the endianness, so just use the native one.
192- u32:: from_ne_bytes ( bytes)
203+ self . blocking_next_u32 ( )
193204 }
194-
195205 fn next_u64 ( & mut self ) -> u64 {
196- let mut bytes = [ 0 ; 8 ] ;
197- self . blocking_fill_bytes ( & mut bytes) ;
198- u64:: from_ne_bytes ( bytes)
206+ self . blocking_next_u64 ( )
199207 }
200-
201- fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , rand_core:: Error > {
208+ fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , rand_core_06:: Error > {
202209 self . blocking_fill_bytes ( dest) ;
203210 Ok ( ( ) )
204211 }
205212}
206213
207- impl < ' d , T : Instance > rand_core:: CryptoRng for Rng < ' d , T > { }
214+ impl < ' d , T : Instance > rand_core_06:: CryptoRng for Rng < ' d , T > { }
215+
216+ impl < ' d , T : Instance > rand_core_09:: RngCore for Rng < ' d , T > {
217+ fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
218+ self . blocking_fill_bytes ( dest) ;
219+ }
220+ fn next_u32 ( & mut self ) -> u32 {
221+ self . blocking_next_u32 ( )
222+ }
223+ fn next_u64 ( & mut self ) -> u64 {
224+ self . blocking_next_u64 ( )
225+ }
226+ }
227+
228+ impl < ' d , T : Instance > rand_core_09:: CryptoRng for Rng < ' d , T > { }
208229
209230/// Peripheral static state
210231pub ( crate ) struct State {
0 commit comments