cryprot_core/
rand_compat.rs1use rand::CryptoRng;
3use rand_core::Rng;
4
5pub struct RngCompat<R>(pub R);
11
12impl<R: Rng> rand_core_0_6::RngCore for RngCompat<R> {
13 #[inline]
14 fn next_u32(&mut self) -> u32 {
15 self.0.next_u32()
16 }
17
18 #[inline]
19 fn next_u64(&mut self) -> u64 {
20 self.0.next_u64()
21 }
22
23 #[inline]
24 fn fill_bytes(&mut self, dest: &mut [u8]) {
25 self.0.fill_bytes(dest);
26 }
27
28 #[inline]
29 fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core_0_6::Error> {
30 self.0.fill_bytes(dest);
31 Ok(())
32 }
33}
34
35impl<R: CryptoRng> rand_core_0_6::CryptoRng for RngCompat<R> {}