Expand description
wasi_virt_layer provides a virtualization layer for WebAssembly System Interface (WASI).
This crate facilitates merging a Virtual File System (VFS) and threading mechanisms into standard WASI modules without modifying their source code in complex ways. It allows a host environment (like browsers via JavaScript bindings) to seamlessly interact with in-memory Wasm modules.
§Core Concepts
- Virtual File System (VFS): Overrides filesystem-related WASI calls to a custom virtualized implementation.
- Threading: Provides components that patch how Wasm spawns and manages threads using shared memory.
- Memory Bridge: Manages memory boundaries and host-guest interaction.
Modules§
- clock
- Clock and time operations.
- file
- Virtual File System operations and definitions.
- memory
- Memory operations to bridge host and WebAssembly memory models.
- poll
- I/O polling and event waiting mechanisms.
- prelude
- Common traits, structs, and macros representing the core functionality.
- process
- Process execution and lifecycle virtualization.
- random
- Random number generation and virtualization.
- wasi
- wasip1
- Definitions and bindings for the original WASIP1 API.
- wasip1_
derive - Procedural macros for generating WASIP1 boilerplate.
Macros§
- __as_t
- Internal helper macro for handle
selfand other identifiers. - __
memory_ director_ import_ etc - Internal macro used to generate memory trap and director imports for WASM access.
- __
memory_ director_ wasm_ access - Internal macro used to generate the
memory_director_rawmethod for WASM access. - import_
wasm - By entering the names of the files to be combined, a bridge for the combination is created. You need to prepare as many Wasip1 instances on the virtual file system as the number of files to be combined.
- non_
recursive_ wasi_ snapshot_ preview1 - Typically, WASI ABI calls are made using plug!. However, there may be cases where you want to call the ABI directly from within plug!. Doing so would result in recursion. To address this, call the function through this macro. When calling a function through this macro, it becomes a proper WASI ABI call after plug is connected. This allows you to call the ABI without causing recursion.
- plug_
args - @embedded or @dynamic Whether to import JavaScript runtime args from vfs, args is automatically imported even if you are not using it, so that you can block it
- plug_
clock - Plugs the clock ecosystem by defining necessary handlers for clock operations.
- plug_
env - @embedded or @dynamic Whether to import JavaScript runtime env from vfs, env is automatically imported even if you are not using it, so that you can block it
- plug_fs
- Plugs the file system ecosystem by defining necessary handlers.
- plug_
poll - Plugs the poll ecosystem by defining necessary handlers.
- plug_
process - Plugs the process exit ecosystem by defining necessary handlers.
- plug_
random - Plugs the random ecosystem by defining necessary handlers.
- wrap_
unreachable - A macro to explicitly wrap WebAssembly’s unreachable instructions for a given Target module.
This generates internal markers interpreted by
wasi_virt_layer-cliduring generation.