Remove rand(), fixes #50

This commit is contained in:
Dario Nieuwenhuis 2021-02-26 01:58:00 +01:00
parent 11be9170ec
commit 17cf301d4f
4 changed files with 1 additions and 27 deletions

View File

@ -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"

View File

@ -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 {

View File

@ -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;

View File

@ -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) }
}