[−][src]Struct wasmer_wasi::state::WasiStateBuilder
Convenient builder API for configuring WASI via WasiState
.
Usage:
let mut state_builder = WasiState::new("wasi-prog-name"); state_builder .env("ENV_VAR", "ENV_VAL") .arg("--verbose") .preopen_dir("src")? .map_dir("name_wasi_sees", "path/on/host/fs")? .build();
Methods
impl WasiStateBuilder
[src]
pub fn env<Key, Value>(&mut self, key: Key, value: Value) -> &mut Self where
Key: AsRef<[u8]>,
Value: AsRef<[u8]>,
[src]
Key: AsRef<[u8]>,
Value: AsRef<[u8]>,
Add an environment variable pair.
Environment variable keys and values must not contain the byte =
(0x3d)
or nul (0x0).
pub fn arg<Arg>(&mut self, arg: Arg) -> &mut Self where
Arg: AsRef<[u8]>,
[src]
Arg: AsRef<[u8]>,
Add an argument. Arguments must not contain the nul (0x0) byte
pub fn envs<I, Key, Value>(&mut self, env_pairs: I) -> &mut Self where
I: IntoIterator<Item = (Key, Value)>,
Key: AsRef<[u8]>,
Value: AsRef<[u8]>,
[src]
I: IntoIterator<Item = (Key, Value)>,
Key: AsRef<[u8]>,
Value: AsRef<[u8]>,
Add multiple environment variable pairs.
Keys and values must not contain the =
(0x3d) or nul (0x0) byte.
pub fn args<I, Arg>(&mut self, args: I) -> &mut Self where
I: IntoIterator<Item = Arg>,
Arg: AsRef<[u8]>,
[src]
I: IntoIterator<Item = Arg>,
Arg: AsRef<[u8]>,
Add multiple arguments. Arguments must not contain the nul (0x0) byte
pub fn preopen_dir<FilePath>(
&mut self,
po_dir: FilePath
) -> Result<&mut Self, WasiStateCreationError> where
FilePath: AsRef<Path>,
[src]
&mut self,
po_dir: FilePath
) -> Result<&mut Self, WasiStateCreationError> where
FilePath: AsRef<Path>,
Preopen a directory
This opens the given directory at the virtual root, /
, and allows
the WASI module to read and write to the given directory.
pub fn preopen<F>(
&mut self,
inner: F
) -> Result<&mut Self, WasiStateCreationError> where
F: Fn(&mut PreopenDirBuilder) -> &mut PreopenDirBuilder,
[src]
&mut self,
inner: F
) -> Result<&mut Self, WasiStateCreationError> where
F: Fn(&mut PreopenDirBuilder) -> &mut PreopenDirBuilder,
Preopen a directory and configure it.
Usage:
WasiState::new("program_name") .preopen(|p| p.directory("src").read(true).write(true).create(true))? .preopen(|p| p.directory(".").alias("dot").read(true))? .build()?;
pub fn preopen_dirs<I, FilePath>(
&mut self,
po_dirs: I
) -> Result<&mut Self, WasiStateCreationError> where
I: IntoIterator<Item = FilePath>,
FilePath: AsRef<Path>,
[src]
&mut self,
po_dirs: I
) -> Result<&mut Self, WasiStateCreationError> where
I: IntoIterator<Item = FilePath>,
FilePath: AsRef<Path>,
Preopen a directory
This opens the given directory at the virtual root, /
, and allows
the WASI module to read and write to the given directory.
pub fn map_dir<FilePath>(
&mut self,
alias: &str,
po_dir: FilePath
) -> Result<&mut Self, WasiStateCreationError> where
FilePath: AsRef<Path>,
[src]
&mut self,
alias: &str,
po_dir: FilePath
) -> Result<&mut Self, WasiStateCreationError> where
FilePath: AsRef<Path>,
Preopen a directory with a different name exposed to the WASI.
pub fn map_dirs<I, FilePath>(
&mut self,
mapped_dirs: I
) -> Result<&mut Self, WasiStateCreationError> where
I: IntoIterator<Item = (String, FilePath)>,
FilePath: AsRef<Path>,
[src]
&mut self,
mapped_dirs: I
) -> Result<&mut Self, WasiStateCreationError> where
I: IntoIterator<Item = (String, FilePath)>,
FilePath: AsRef<Path>,
Preopen directorys with a different names exposed to the WASI.
pub fn stdout(&mut self, new_file: Box<dyn WasiFile>) -> &mut Self
[src]
Overwrite the default WASI stdout
, if you want to hold on to the
original stdout
use WasiFs::swap_file
after building.
pub fn stderr(&mut self, new_file: Box<dyn WasiFile>) -> &mut Self
[src]
Overwrite the default WASI stderr
, if you want to hold on to the
original stderr
use WasiFs::swap_file
after building.
pub fn stdin(&mut self, new_file: Box<dyn WasiFile>) -> &mut Self
[src]
Overwrite the default WASI stdin
, if you want to hold on to the
original stdin
use WasiFs::swap_file
after building.
pub fn setup_fs(
&mut self,
setup_fs_fn: Box<dyn Fn(&mut WasiFs) -> Result<(), String> + Send>
) -> &mut Self
[src]
&mut self,
setup_fs_fn: Box<dyn Fn(&mut WasiFs) -> Result<(), String> + Send>
) -> &mut Self
Setup the WASI filesystem before running
pub fn build(&mut self) -> Result<WasiState, WasiStateCreationError>
[src]
Consumes the WasiStateBuilder
and produces a WasiState
Returns the error from WasiFs::new
if there's an error
Trait Implementations
impl Debug for WasiStateBuilder
[src]
impl Default for WasiStateBuilder
[src]
fn default() -> WasiStateBuilder
[src]
Auto Trait Implementations
impl !RefUnwindSafe for WasiStateBuilder
impl Send for WasiStateBuilder
impl !Sync for WasiStateBuilder
impl Unpin for WasiStateBuilder
impl !UnwindSafe for WasiStateBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,