From 17cf301d4fdc3bc0b1356ed250bfacca0d67ef3e Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 26 Feb 2021 01:58:00 +0100 Subject: [PATCH] Remove rand(), fixes #50 --- embassy-std/Cargo.toml | 3 +-- embassy-std/src/lib.rs | 9 --------- embassy/src/lib.rs | 1 - embassy/src/rand.rs | 15 --------------- 4 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 embassy/src/rand.rs diff --git a/embassy-std/Cargo.toml b/embassy-std/Cargo.toml index 2a802813..0a59999c 100644 --- a/embassy-std/Cargo.toml +++ b/embassy-std/Cargo.toml @@ -6,5 +6,4 @@ edition = "2018" [dependencies] embassy = { version = "0.1.0", path = "../embassy", features = ["std"] } -lazy_static = "1.4.0" -rand_core = { version = "0.6.0", features = ["std"] } +lazy_static = "1.4.0" \ No newline at end of file diff --git a/embassy-std/src/lib.rs b/embassy-std/src/lib.rs index 29f4de42..688054cb 100644 --- a/embassy-std/src/lib.rs +++ b/embassy-std/src/lib.rs @@ -1,7 +1,6 @@ use embassy::executor::{raw, Spawner}; use embassy::time::TICKS_PER_SECOND; use embassy::time::{Alarm, Clock}; -use rand_core::{OsRng, RngCore}; use std::marker::PhantomData; use std::mem::MaybeUninit; use std::ptr; @@ -19,13 +18,6 @@ impl Clock for StdClock { } } -struct StdRand; -impl embassy::rand::Rand for StdRand { - fn rand(&self, buf: &mut [u8]) { - OsRng.fill_bytes(buf); - } -} - static mut ALARM_AT: u64 = u64::MAX; pub struct StdAlarm; @@ -101,7 +93,6 @@ impl Executor { unsafe { CLOCK_ZERO.as_mut_ptr().write(StdInstant::now()); embassy::time::set_clock(&StdClock); - embassy::rand::set_rand(&StdRand); } Self { diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs index cab61080..0844df37 100644 --- a/embassy/src/lib.rs +++ b/embassy/src/lib.rs @@ -13,7 +13,6 @@ pub mod flash; pub mod gpio; pub mod interrupt; pub mod io; -pub mod rand; pub mod time; pub mod uart; pub mod util; diff --git a/embassy/src/rand.rs b/embassy/src/rand.rs deleted file mode 100644 index 7e378838..00000000 --- a/embassy/src/rand.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::fmt::*; - -pub trait Rand { - fn rand(&self, buf: &mut [u8]); -} - -static mut RAND: Option<&'static dyn Rand> = None; - -pub unsafe fn set_rand(rand: &'static dyn Rand) { - RAND = Some(rand); -} - -pub fn rand(buf: &mut [u8]) { - unsafe { unwrap!(RAND, "No rand set").rand(buf) } -}