pub struct Wasi {Show 19 fields
pub(crate) pre_opened_directories: Vec<PathBuf>,
pub(crate) mapped_dirs: Vec<MappedDirectory>,
pub(crate) env_vars: Vec<(String, String)>,
pub(crate) forward_host_env: bool,
pub(crate) uses: Vec<String>,
pub(super) include_webcs: Vec<PathBuf>,
pub(super) map_commands: Vec<String>,
pub networking: Option<Option<String>>,
pub no_tty: bool,
pub enable_async_threads: bool,
pub enable_cpu_backoff: Option<u64>,
pub journals: Vec<PathBuf>,
pub enable_compaction: bool,
pub without_compact_on_drop: bool,
pub with_compact_on_growth: f32,
pub snapshot_on: Vec<SnapshotTrigger>,
pub snapshot_interval: Option<u64>,
pub http_client: bool,
pub deny_multiple_wasi_versions: bool,
}
Expand description
WASI Options
Fields§
§pre_opened_directories: Vec<PathBuf>
WASI pre-opened directory
mapped_dirs: Vec<MappedDirectory>
Map a host directory to a different location for the Wasm module
env_vars: Vec<(String, String)>
Pass custom environment variables
forward_host_env: bool
Forward all host env variables to guest
uses: Vec<String>
List of other containers this module depends on
include_webcs: Vec<PathBuf>
List of webc packages that are explicitly included for execution Note: these packages will be used instead of those in the registry
map_commands: Vec<String>
List of injected atoms
networking: Option<Option<String>>
Enable networking with the host network.
Allows WASI modules to open TCP and UDP connections, create sockets, …
Optionally, a set of network filters could be defined which allows fine-grained control over the network sandbox.
Rule Syntax:
Examples:
-
Allow a specific domain and port: dns:allow=example.com:80
-
Deny a domain and all its subdomains on all ports: dns:deny=danger.xyz:
-
Allow opening ipv4 sockets only on a specific IP and port: ipv4:allow=127.0.0.1:80/in.
no_tty: bool
Disables the TTY bridge
enable_async_threads: bool
Enables asynchronous threading
enable_cpu_backoff: Option<u64>
Enables an exponential backoff (measured in milli-seconds) of the process CPU usage when there are no active run tokens (when set holds the maximum amount of time that it will pause the CPU) (default = off)
journals: Vec<PathBuf>
Specifies one or more journal files that Wasmer will use to restore and save the state of the WASM process as it executes.
The state of the WASM process and its sandbox will be reapplied using the journals in the order that you specify here.
The last journal file specified will be created if it does not exist and opened for read and write. New journal events will be written to this file
enable_compaction: bool
Flag that indicates if the journal will be automatically compacted as it fills up and when the process exits
without_compact_on_drop: bool
Tells the compactor not to compact when the journal log file is closed
with_compact_on_growth: f32
Tells the compactor to compact when it grows by a certain factor of its original size. (i.e. ‘0.2’ would be it compacts after the journal has grown by 20 percent)
Default is to compact on growth that exceeds 15%
snapshot_on: Vec<SnapshotTrigger>
Indicates what events will cause a snapshot to be taken and written to the journal file.
If not specified, the default is to snapshot when the process idles, when the process exits or periodically if an interval argument is also supplied, as well as when the process requests a snapshot explicitly.
Additionally if the snapshot-on is not specified it will also take a snapshot on the first stdin, environ or socket listen - this can be used to accelerate the boot up time of WASM processes.
snapshot_interval: Option<u64>
Adds a periodic interval (measured in milli-seconds) that the runtime will automatically
take snapshots of the running process and write them to the journal. When specifying
this parameter it implies that --snapshot-on interval
has also been specified.
http_client: bool
Allow instances to send http requests.
Access to domains is granted by default.
deny_multiple_wasi_versions: bool
Require WASI modules to only import 1 version of WASI.
Implementations§
source§impl Wasi
impl Wasi
pub fn map_dir(&mut self, alias: &str, target_on_disk: PathBuf)
pub fn set_env(&mut self, key: &str, value: &str)
sourcepub fn get_versions(module: &Module) -> Option<BTreeSet<WasiVersion>>
pub fn get_versions(module: &Module) -> Option<BTreeSet<WasiVersion>>
Gets the WASI version (if any) for the provided module
sourcepub fn has_wasi_imports(module: &Module) -> bool
pub fn has_wasi_imports(module: &Module) -> bool
Checks if a given module has any WASI imports at all.
pub fn prepare( &self, module: &Module, program_name: String, args: Vec<String>, rt: Arc<dyn Runtime + Send + Sync>, ) -> Result<WasiEnvBuilder>
pub fn build_journals(&self) -> Result<Vec<Arc<DynJournal>>>
pub fn build_mapped_directories( &self, ) -> Result<(bool, bool, Vec<MappedDirectory>), Error>
pub fn build_mapped_commands(&self) -> Result<Vec<MappedCommand>, Error>
pub fn capabilities(&self) -> Capabilities
pub fn prepare_runtime<I>(
&self,
engine: Engine,
env: &WasmerEnv,
pkg_cache_path: &Path,
rt_or_handle: I,
preferred_webc_version: Version,
) -> Result<impl Runtime + Send + Sync>where
I: Into<RuntimeOrHandle>,
sourcepub fn instantiate(
&self,
module: &Module,
module_hash: ModuleHash,
program_name: String,
args: Vec<String>,
runtime: Arc<dyn Runtime + Send + Sync>,
store: &mut Store,
) -> Result<(WasiFunctionEnv, Instance)>
pub fn instantiate( &self, module: &Module, module_hash: ModuleHash, program_name: String, args: Vec<String>, runtime: Arc<dyn Runtime + Send + Sync>, store: &mut Store, ) -> Result<(WasiFunctionEnv, Instance)>
Helper function for instantiating a module with Wasi imports for the Run
command.
pub fn for_binfmt_interpreter() -> Result<Self>
fn prepare_package_loader( &self, env: &WasmerEnv, client: Arc<dyn HttpClient + Send + Sync>, ) -> Result<impl PackageLoader>
fn prepare_source( &self, env: &WasmerEnv, client: Arc<dyn HttpClient + Send + Sync>, preferred_webc_version: Version, ) -> Result<impl Source + Send>
fn graphql_endpoint(&self, env: &WasmerEnv) -> Result<Url>
Trait Implementations§
source§impl Args for Wasi
impl Args for Wasi
source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
ArgGroup::id
][crate::ArgGroup::id] for this set of argumentssource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
source§impl FromArgMatches for Wasi
impl FromArgMatches for Wasi
source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches
to self
.source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches
to self
.source§impl Parser for Wasi
impl Parser for Wasi
§fn parse_from<I, T>(itr: I) -> Self
fn parse_from<I, T>(itr: I) -> Self
§fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
§fn update_from<I, T>(&mut self, itr: I)
fn update_from<I, T>(&mut self, itr: I)
§fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
Auto Trait Implementations§
impl Freeze for Wasi
impl RefUnwindSafe for Wasi
impl Send for Wasi
impl Sync for Wasi
impl Unpin for Wasi
impl UnwindSafe for Wasi
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more