embassy/embassy-traits/src/rng.rs

26 lines
751 B
Rust
Raw Normal View History

2021-04-26 15:43:19 +02:00
use core::future::Future;
/// Random-number Generator
pub trait Rng {
type Error;
2021-08-27 22:10:01 +02:00
#[rustfmt::skip]
2021-04-26 15:43:19 +02:00
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_bytes<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>;
2021-08-27 22:10:01 +02:00
#[rustfmt::skip]
type NextFuture<'a>: Future<Output = Result<u32, Self::Error>> + 'a
where
Self: 'a;
fn next<'a>(&'a mut self, range: u32) -> Self::NextFuture<'a>;
2021-04-26 15:43:19 +02:00
}