pecos_core/sims_rngs/
cyclic_rng.rs

1// Copyright 2024 The PECOS Developers
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4// in compliance with the License.You may obtain a copy of the License at
5//
6//     https://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software distributed under the License
9// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10// or implied. See the License for the specific language governing permissions and limitations under
11// the License.
12
13use super::sim_rng::SimRng;
14use rand::{Error, RngCore, SeedableRng};
15
16const N: usize = 64;
17
18#[derive(Debug)]
19pub struct CyclicSeed(pub [u8; N]);
20
21impl Default for CyclicSeed {
22    #[inline]
23    fn default() -> Self {
24        Self([0; N])
25    }
26}
27
28impl AsMut<[u8]> for CyclicSeed {
29    #[inline]
30    fn as_mut(&mut self) -> &mut [u8] {
31        &mut self.0
32    }
33}
34
35#[allow(unused)]
36#[derive(Debug)]
37pub struct CyclicRng {
38    seed: CyclicSeed,
39    bools: Vec<bool>,
40}
41
42impl CyclicRng {
43    #[allow(dead_code)]
44    #[inline]
45    fn set_bools(&mut self, bools: &[bool]) {
46        bools.clone_into(&mut self.bools);
47    }
48}
49
50impl RngCore for CyclicRng {
51    #[allow(unused)]
52    #[inline]
53    fn next_u32(&mut self) -> u32 {
54        todo!()
55    }
56
57    #[allow(unused)]
58    #[inline]
59    fn next_u64(&mut self) -> u64 {
60        todo!()
61    }
62
63    #[allow(unused)]
64    #[inline]
65    fn fill_bytes(&mut self, dest: &mut [u8]) {
66        todo!()
67    }
68
69    #[allow(unused)]
70    #[inline]
71    fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
72        todo!()
73    }
74}
75
76impl SeedableRng for CyclicRng {
77    type Seed = CyclicSeed;
78
79    #[inline]
80    fn from_seed(seed: Self::Seed) -> Self {
81        Self {
82            seed,
83            bools: vec![],
84        }
85    }
86}
87
88impl SimRng for CyclicRng {}