File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ stm32l4 = "0.13.0"
27
27
as-slice = " 0.1"
28
28
generic-array = " 0.13"
29
29
30
+ [dependencies .rand_core ]
31
+ version = " 0.6.2"
32
+ default-features = false
33
+
30
34
[dependencies .cast ]
31
35
version = " 0.2.2"
32
36
default-features = false
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use core::cmp;
4
4
5
5
use crate :: rcc:: { Clocks , AHB2 } ;
6
6
use crate :: stm32:: RNG ;
7
+ pub use rand_core:: RngCore ;
7
8
8
9
/// Extension trait to activate the RNG
9
10
pub trait RngExt {
@@ -91,6 +92,24 @@ impl Rng {
91
92
}
92
93
}
93
94
95
+ impl RngCore for Rng {
96
+ fn next_u32 ( & mut self ) -> u32 {
97
+ self . get_random_data ( )
98
+ }
99
+
100
+ fn next_u64 ( & mut self ) -> u64 {
101
+ rand_core:: impls:: next_u64_via_u32 ( self )
102
+ }
103
+
104
+ fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
105
+ rand_core:: impls:: fill_bytes_via_next ( self , dest)
106
+ }
107
+
108
+ fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , rand_core:: Error > {
109
+ Ok ( self . fill_bytes ( dest) )
110
+ }
111
+ }
112
+
94
113
#[ derive( Debug ) ]
95
114
pub enum Error { }
96
115
You can’t perform that action at this time.
0 commit comments