Struct wasmer_ruby::Wasmer::Wasi::StateBuilder
source · pub struct StateBuilder;
Expand description
Convenient builder API for configuring WASI.
Use the constructor to pass the arguments, environments, preopen directories and map directories, or use the associated methods to build the state step-by-steps.
Implementations§
source§impl StateBuilder
impl StateBuilder
pub fn new(program_name: String) -> Self
sourcepub fn argument(&mut self, argument: String) -> Self
pub fn argument(&mut self, argument: String) -> Self
Adds an argument.
Arguments must not contain the nul (0x0
) byte.
sourcepub fn arguments(&mut self, arguments: Array<String>) -> Self
pub fn arguments(&mut self, arguments: Array<String>) -> Self
Adds multiple arguments.
Arguments must not contain the nul (0x0
) byte.
sourcepub fn environment(&mut self, key: String, value: String) -> Self
pub fn environment(&mut self, key: String, value: String) -> Self
Add an environment variable pair.
Environment variable keys and values must not contain
the byte =
(0x3d
) or null (0x0
).
sourcepub fn environments(&mut self, pairs: Hash<String, String>) -> Self
pub fn environments(&mut self, pairs: Hash<String, String>) -> Self
Add environment variable pairs.
Environment variable keys and values must not contain
the byte =
(0x3d
) or null (0x0
).
sourcepub fn preopen_directory(&mut self, alias: String, value: String) -> Self
pub fn preopen_directory(&mut self, alias: String, value: String) -> Self
Preopen a directory with a different name exposed to the WASI.
This opens the given directories at the virtual root,
/
, and allows the WASI module to read and write to the
given directories.
sourcepub fn preopen_directories(&mut self, pairs: Hash<String, String>) -> Self
pub fn preopen_directories(&mut self, pairs: Hash<String, String>) -> Self
Preopen directories with a different name exposed to the WASI.
This opens the given directories at the virtual root,
/
, and allows the WASI module to read and write to the
given directories.
sourcepub fn map_directory(&mut self, alias: String, value: String) -> Self
pub fn map_directory(&mut self, alias: String, value: String) -> Self
Preopen a directory with a different name exposed to the WASI.
sourcepub fn map_directories(&mut self, pairs: Hash<String, String>) -> Self
pub fn map_directories(&mut self, pairs: Hash<String, String>) -> Self
Preopen directories with a different name exposed to the WASI.
sourcepub fn finalize(&mut self) -> Environment
pub fn finalize(&mut self) -> Environment
Produces a WASI Environment
based on this state builder.