1
pub(crate) struct FakePRNG<'a> {
2
    bytes: &'a [u8],
3
}
4
impl<'a> FakePRNG<'a> {
5
10
    pub(crate) fn new(bytes: &'a [u8]) -> Self {
6
10
        Self { bytes }
7
10
    }
8
}
9
impl<'a> rand_core::RngCore for FakePRNG<'a> {
10
    fn next_u32(&mut self) -> u32 {
11
        rand_core::impls::next_u32_via_fill(self)
12
    }
13
    fn next_u64(&mut self) -> u64 {
14
        rand_core::impls::next_u64_via_fill(self)
15
    }
16
10
    fn fill_bytes(&mut self, dest: &mut [u8]) {
17
10
        assert!(dest.len() <= self.bytes.len());
18

            
19
10
        dest.copy_from_slice(&self.bytes[0..dest.len()]);
20
10
        self.bytes = &self.bytes[dest.len()..];
21
10
    }
22
}
23
impl rand_core::CryptoRng for FakePRNG<'_> {}