aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-traits/src/lib.rs1
-rw-r--r--embassy-traits/src/rng.rs17
2 files changed, 18 insertions, 0 deletions
diff --git a/embassy-traits/src/lib.rs b/embassy-traits/src/lib.rs
index ea59444c1..1ce5dbe7e 100644
--- a/embassy-traits/src/lib.rs
+++ b/embassy-traits/src/lib.rs
@@ -14,3 +14,4 @@ pub mod gpio;
14pub mod i2c; 14pub mod i2c;
15pub mod spi; 15pub mod spi;
16pub mod uart; 16pub mod uart;
17pub mod rng;
diff --git a/embassy-traits/src/rng.rs b/embassy-traits/src/rng.rs
new file mode 100644
index 000000000..af786bd4a
--- /dev/null
+++ b/embassy-traits/src/rng.rs
@@ -0,0 +1,17 @@
1use core::future::Future;
2
3/// Random-number Generator
4pub trait Rng {
5 type Error;
6
7 type RngFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
8 where
9 Self: 'a;
10
11 /// Completely fill the provided buffer with random bytes.
12 ///
13 /// May result in delays if entropy is exhausted prior to completely
14 /// filling the buffer. Upon completion, the buffer will be completely
15 /// filled or an error will have been reported.
16 fn fill<'a>(&'a mut self, dest: &'a mut [u8]) -> Self::RngFuture<'a>;
17}