[][src]Struct wasmer_wasi_fl::state::WasiStateBuilder

pub struct WasiStateBuilder { /* fields omitted */ }

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();

Implementations

impl WasiStateBuilder[src]

pub fn env<Key, Value>(&mut self, key: Key, value: Value) -> &mut Self where
    Key: AsRef<[u8]>,
    Value: AsRef<[u8]>, 
[src]

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]

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]

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]

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]

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]

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]

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]

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]

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]

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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.