Skip to content

Commit 2e8d6ac

Browse files
committed
Add nonblocking RNG trait
1 parent a5c0e3c commit 2e8d6ac

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ pub mod blocking;
694694
pub mod digital;
695695
pub mod fmt;
696696
pub mod prelude;
697+
#[cfg(feature = "unproven")]
698+
pub mod rng;
697699
pub mod serial;
698700
pub mod spi;
699701
pub mod timer;

src/prelude.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub use digital::OutputPin as _embedded_hal_digital_OutputPin;
2525
#[cfg(feature = "unproven")]
2626
#[allow(deprecated)]
2727
pub use digital::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin;
28+
#[cfg(feature = "unproven")]
29+
pub use rng::Read as _embedded_hal_rng_Read;
2830
pub use serial::Read as _embedded_hal_serial_Read;
2931
pub use serial::Write as _embedded_hal_serial_Write;
3032
pub use spi::FullDuplex as _embedded_hal_spi_FullDuplex;

src/rng.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Random Number Generator Interface
2+
3+
use nb;
4+
5+
/// Nonblocking stream of random bytes.
6+
#[cfg(feature = "unproven")]
7+
// reason: No implementation or users yet
8+
pub trait Read {
9+
/// An enumeration of RNG errors.
10+
///
11+
/// For infallible implementations, will be `Void`
12+
type Error;
13+
14+
/// Get a number of bytes from the RNG.
15+
fn read(&mut self, buf: &mut [u8]) -> nb::Result<usize, Self::Error>;
16+
}

0 commit comments

Comments
 (0)