Struct wasmer_wasi::WasiState

source ·
pub struct WasiState {
    pub fs: WasiFs,
    pub inodes: Arc<RwLock<WasiInodes>>,
    pub args: Vec<Vec<u8>>,
    pub envs: Vec<Vec<u8>>,
    /* private fields */
}
Expand description

Top level data type containing all* the state with which WASI can interact.

  • The contents of files are not stored and may be modified by other, concurrently running programs. Data such as the contents of directories are lazily loaded.

Usage:

WasiState::new("program_name")
   .env(b"HOME", "/home/home".to_string())
   .arg("--help")
   .envs({
       let mut hm = std::collections::HashMap::new();
       hm.insert("COLOR_OUTPUT", "TRUE");
       hm.insert("PATH", "/usr/bin");
       hm
   })
   .args(&["--verbose", "list"])
   .preopen(|p| p.directory("src").read(true).write(true).create(true))?
   .preopen(|p| p.directory(".").alias("dot").read(true))?
   .build()?;

Fields§

§fs: WasiFs§inodes: Arc<RwLock<WasiInodes>>§args: Vec<Vec<u8>>§envs: Vec<Vec<u8>>

Implementations§

Create a WasiStateBuilder to construct a validated instance of WasiState.

Get the VirtualFile object at stdout

👎Deprecated since 3.0.0: stdout_mut() is no longer needed - just use stdout() instead

Get the VirtualFile object at stderr

👎Deprecated since 3.0.0: stderr_mut() is no longer needed - just use stderr() instead

Get the VirtualFile object at stdin

👎Deprecated since 3.0.0: stdin_mut() is no longer needed - just use stdin() instead

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type for metadata in pointers and references to Self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
upcast ref
upcast mut ref
upcast boxed dyn
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more