Struct wasmtime_cli_flags::WasiModules
source · Expand description
Select which WASI modules are available at runtime for use by Wasm programs.
Fields§
§wasi_common: bool
Enable the wasi-common implementation; eventually this should be split into its separate parts once the implementation allows for it (e.g. wasi-fs, wasi-clocks, etc.).
wasi_nn: bool
Enable the experimental wasi-nn implementation
wasi_crypto: bool
Enable the experimental wasi-crypto implementation
Implementations§
source§impl WasiModules
impl WasiModules
sourcepub fn none() -> Self
pub fn none() -> Self
Enable no modules.
Examples found in repository?
src/lib.rs (line 472)
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
fn parse_wasi_modules(modules: &str) -> Result<WasiModules> {
let modules = modules.trim();
match modules {
"default" => Ok(WasiModules::default()),
"-default" => Ok(WasiModules::none()),
_ => {
// Starting from the default set of WASI modules, enable or disable a list of
// comma-separated modules.
let mut wasi_modules = WasiModules::default();
let mut set = |module: &str, enable: bool| match module {
"" => Ok(()),
"wasi-common" => Ok(wasi_modules.wasi_common = enable),
"experimental-wasi-nn" => Ok(wasi_modules.wasi_nn = enable),
"experimental-wasi-crypto" => Ok(wasi_modules.wasi_crypto = enable),
"default" => bail!("'default' cannot be specified with other WASI modules"),
_ => bail!("unsupported WASI module '{}'", module),
};
for module in modules.split(',') {
let module = module.trim();
let (module, value) = if module.starts_with('-') {
(&module[1..], false)
} else {
(module, true)
};
set(module, value)?;
}
Ok(wasi_modules)
}
}
}
Trait Implementations§
source§impl Clone for WasiModules
impl Clone for WasiModules
source§fn clone(&self) -> WasiModules
fn clone(&self) -> WasiModules
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for WasiModules
impl Debug for WasiModules
source§impl Default for WasiModules
impl Default for WasiModules
source§impl PartialEq<WasiModules> for WasiModules
impl PartialEq<WasiModules> for WasiModules
source§fn eq(&self, other: &WasiModules) -> bool
fn eq(&self, other: &WasiModules) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.