Struct wasmer_cli::commands::run::wasi::Wasi

source ·
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:

:<allow|deny>=

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

source

pub fn map_dir(&mut self, alias: &str, target_on_disk: PathBuf)

source

pub fn set_env(&mut self, key: &str, value: &str)

source

pub fn get_versions(module: &Module) -> Option<BTreeSet<WasiVersion>>

Gets the WASI version (if any) for the provided module

source

pub fn has_wasi_imports(module: &Module) -> bool

Checks if a given module has any WASI imports at all.

source

pub fn prepare( &self, module: &Module, program_name: String, args: Vec<String>, rt: Arc<dyn Runtime + Send + Sync>, ) -> Result<WasiEnvBuilder>

source

pub fn build_journals(&self) -> Result<Vec<Arc<DynJournal>>>

source

pub fn build_mapped_directories( &self, ) -> Result<(bool, bool, Vec<MappedDirectory>), Error>

source

pub fn build_mapped_commands(&self) -> Result<Vec<MappedCommand>, Error>

source

pub fn capabilities(&self) -> Capabilities

source

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>,

source

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.

source

pub fn for_binfmt_interpreter() -> Result<Self>

source

fn prepare_package_loader( &self, env: &WasmerEnv, client: Arc<dyn HttpClient + Send + Sync>, ) -> Result<impl PackageLoader>

source

fn prepare_source( &self, env: &WasmerEnv, client: Arc<dyn HttpClient + Send + Sync>, preferred_webc_version: Version, ) -> Result<impl Source + Send>

source

fn graphql_endpoint(&self, env: &WasmerEnv) -> Result<Url>

Trait Implementations§

source§

impl Args for Wasi

source§

fn group_id() -> Option<Id>

Report the [ArgGroup::id][crate::ArgGroup::id] for this set of arguments
source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to [Command] so it can instantiate Self. Read more
source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to [Command] so it can update self. Read more
source§

impl Clone for Wasi

source§

fn clone(&self) -> Wasi

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CommandFactory for Wasi

source§

fn command<'b>() -> Command

Build a [Command] that can instantiate Self. Read more
source§

fn command_for_update<'b>() -> Command

Build a [Command] that can update self. Read more
source§

impl Debug for Wasi

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Wasi

source§

fn default() -> Wasi

Returns the “default value” for a type. Read more
source§

impl FromArgMatches for Wasi

source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from [ArgMatches], parsing the arguments as needed. Read more
source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

impl Parser for Wasi

§

fn parse() -> Self

Parse from std::env::args_os(), exit on error
§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error
§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error
§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on 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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
§

impl<T> Upcastable for T
where T: Any + Debug + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> IsFieldType<T> for T

§

impl<T> MaybeSendSync for T