Add an RNG trait.

This commit is contained in:
Bob McWhirter 2021-04-26 09:43:19 -04:00
parent 936efd164d
commit dc919c236d
2 changed files with 18 additions and 0 deletions

View File

@ -14,3 +14,4 @@ pub mod gpio;
pub mod i2c;
pub mod spi;
pub mod uart;
pub mod rng;

17
embassy-traits/src/rng.rs Normal file
View File

@ -0,0 +1,17 @@
use core::future::Future;
/// Random-number Generator
pub trait Rng {
type Error;
type RngFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where
Self: 'a;
/// Completely fill the provided buffer with random bytes.
///
/// May result in delays if entropy is exhausted prior to completely
/// filling the buffer. Upon completion, the buffer will be completely
/// filled or an error will have been reported.
fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>;
}