@@ -66,12 +66,12 @@ impl WasiCtxBuilder {
|
||||
Ok(self.0)
|
||||
}
|
||||
|
||||
pub fn arg(&mut self, arg: &str) -> Result<&mut Self, StringArrayError> {
|
||||
pub fn arg(mut self, arg: &str) -> Result<Self, StringArrayError> {
|
||||
self.0.args.push(arg.to_owned())?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn stdin(&mut self, f: Box<dyn WasiFile>) -> &mut Self {
|
||||
pub fn stdin(mut self, f: Box<dyn WasiFile>) -> Self {
|
||||
self.0.insert_file(
|
||||
0,
|
||||
f,
|
||||
@@ -80,7 +80,7 @@ impl WasiCtxBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn stdout(&mut self, f: Box<dyn WasiFile>) -> &mut Self {
|
||||
pub fn stdout(mut self, f: Box<dyn WasiFile>) -> Self {
|
||||
self.0.insert_file(
|
||||
1,
|
||||
f,
|
||||
@@ -89,7 +89,7 @@ impl WasiCtxBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn stderr(&mut self, f: Box<dyn WasiFile>) -> &mut Self {
|
||||
pub fn stderr(mut self, f: Box<dyn WasiFile>) -> Self {
|
||||
self.0.insert_file(
|
||||
2,
|
||||
f,
|
||||
@@ -98,17 +98,17 @@ impl WasiCtxBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn inherit_stdio(&mut self) -> &mut Self {
|
||||
pub fn inherit_stdio(self) -> Self {
|
||||
self.stdin(Box::new(crate::stdio::stdin()))
|
||||
.stdout(Box::new(crate::stdio::stdout()))
|
||||
.stderr(Box::new(crate::stdio::stderr()))
|
||||
}
|
||||
|
||||
pub fn preopened_dir(
|
||||
&mut self,
|
||||
mut self,
|
||||
dir: Box<dyn WasiDir>,
|
||||
path: impl AsRef<Path>,
|
||||
) -> Result<&mut Self, Error> {
|
||||
) -> Result<Self, Error> {
|
||||
let caps = DirCaps::all();
|
||||
let file_caps = FileCaps::all();
|
||||
self.0.table().push(Box::new(DirEntry::new(
|
||||
@@ -120,7 +120,7 @@ impl WasiCtxBuilder {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn random(&mut self, random: Box<dyn RngCore>) -> &mut Self {
|
||||
pub fn random(mut self, random: Box<dyn RngCore>) -> Self {
|
||||
self.0.random.replace(random);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ mod string_array;
|
||||
pub mod table;
|
||||
pub mod virt;
|
||||
|
||||
pub use ctx::WasiCtx;
|
||||
pub use dir::{DirCaps, WasiDir};
|
||||
pub use cap_fs_ext::SystemTimeSpec;
|
||||
pub use ctx::{WasiCtx, WasiCtxBuilder};
|
||||
pub use dir::{DirCaps, ReaddirCursor, ReaddirEntity, WasiDir};
|
||||
pub use error::Error;
|
||||
pub use file::{FileCaps, WasiFile};
|
||||
pub use file::{FdFlags, FileCaps, Filestat, OFlags, WasiFile};
|
||||
pub use string_array::StringArrayError;
|
||||
|
||||
@@ -12,7 +12,7 @@ impl Table {
|
||||
pub fn new() -> Self {
|
||||
Table {
|
||||
map: HashMap::new(),
|
||||
next_key: 0,
|
||||
next_key: 3, // 0, 1 and 2 are reserved for stdio
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
pub use wasi_c2::WasiCtx;
|
||||
pub use wasi_c2::{
|
||||
Error, FdFlags, FileCaps, Filestat, OFlags, ReaddirCursor, ReaddirEntity, SystemTimeSpec,
|
||||
WasiCtx, WasiCtxBuilder, WasiDir, WasiFile,
|
||||
};
|
||||
|
||||
// Defines a `struct Wasi` with member fields and appropriate APIs for dealing
|
||||
// with all the various WASI exports.
|
||||
|
||||
Reference in New Issue
Block a user