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