implement randomness
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::dir::{DirCaps, DirEntry, WasiDir};
|
||||
use crate::file::{FileCaps, FileEntry, WasiFile};
|
||||
use crate::random::WasiRandom;
|
||||
use crate::string_array::{StringArray, StringArrayError};
|
||||
use crate::table::Table;
|
||||
use crate::Error;
|
||||
@@ -10,6 +11,7 @@ use std::rc::Rc;
|
||||
pub struct WasiCtx {
|
||||
pub(crate) args: StringArray,
|
||||
pub(crate) env: StringArray,
|
||||
pub(crate) random: Box<dyn WasiRandom>,
|
||||
table: Rc<RefCell<Table>>,
|
||||
}
|
||||
|
||||
@@ -22,6 +24,7 @@ impl WasiCtx {
|
||||
WasiCtx {
|
||||
args: StringArray::new(),
|
||||
env: StringArray::new(),
|
||||
random: Box::new(crate::random::GetRandom),
|
||||
table: Rc::new(RefCell::new(Table::new())),
|
||||
}
|
||||
}
|
||||
@@ -110,4 +113,9 @@ impl WasiCtxBuilder {
|
||||
)))?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn random(&mut self, random: Box<dyn WasiRandom>) -> &mut Self {
|
||||
self.0.random = random;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user