Skip to content

Commit 6b5b26d

Browse files
authored
Merge pull request #45 from therealprof/features/rng
Added new (yet unproven) blocking Read trait for a rngs
2 parents 9efc24c + 196b0b6 commit 6b5b26d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/blocking/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pub mod delay;
88
pub mod i2c;
99
pub mod serial;
1010
pub mod spi;
11+
pub mod rng;

src/blocking/rng.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Blocking hardware random number generator
2+
3+
/// Blocking read
4+
#[cfg(feature = "unproven")]
5+
pub trait Read {
6+
/// Error type
7+
type Error;
8+
9+
/// Reads enough bytes from hardware random number generator to fill `buffer`
10+
///
11+
/// If any error is encountered then this function immediately returns. The contents of buf are
12+
/// unspecified in this case.
13+
///
14+
/// If this function returns an error, it is unspecified how many bytes it has read, but it
15+
/// will never read more than would be necessary to completely fill the buffer.
16+
fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error>;
17+
}

src/prelude.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub use ::blocking::spi::{
2323
Transfer as _embedded_hal_blocking_spi_Transfer,
2424
Write as _embedded_hal_blocking_spi_Write,
2525
};
26+
#[cfg(feature = "unproven")]
27+
pub use ::blocking::rng::Read as _embedded_hal_blocking_rng_Read;
2628
pub use ::digital::OutputPin as _embedded_hal_digital_OutputPin;
2729
#[cfg(feature = "unproven")]
2830
pub use ::digital::InputPin as _embedded_hal_digital_InputPin;

0 commit comments

Comments
 (0)