Insulate API from intricacies of memory mgmt of calling runtimes
This commit is contained in:
22
src/ctx.rs
22
src/ctx.rs
@@ -1,6 +1,5 @@
|
||||
use crate::fdentry::FdEntry;
|
||||
use crate::host;
|
||||
use crate::wasm32;
|
||||
|
||||
use failure::{bail, format_err, Error};
|
||||
use nix::unistd::dup;
|
||||
@@ -11,17 +10,6 @@ use std::io::{stderr, stdin, stdout};
|
||||
use std::os::unix::prelude::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub trait VmContext {
|
||||
fn as_wasi_ctx(&self) -> *const WasiCtx;
|
||||
fn as_wasi_ctx_mut(&mut self) -> *mut WasiCtx;
|
||||
|
||||
unsafe fn dec_ptr(
|
||||
&mut self,
|
||||
ptr: wasm32::uintptr_t,
|
||||
len: usize,
|
||||
) -> Result<*mut u8, host::__wasi_errno_t>;
|
||||
}
|
||||
|
||||
pub struct WasiCtxBuilder {
|
||||
fds: HashMap<host::__wasi_fd_t, FdEntry>,
|
||||
preopens: HashMap<PathBuf, File>,
|
||||
@@ -198,16 +186,6 @@ pub struct WasiCtx {
|
||||
pub env: Vec<CString>,
|
||||
}
|
||||
|
||||
impl Default for WasiCtx {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
fds: HashMap::new(),
|
||||
args: Vec::new(),
|
||||
env: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WasiCtx {
|
||||
/// Make a new `WasiCtx` with some default settings.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user