Skip to main content

Module wasm_runtime

Module wasm_runtime 

Source
Expand description

WASM Plugin Runtime Module

Provides WebAssembly-based plugin execution for MoFA:

  • Sandboxed plugin execution
  • Host function interface for plugins
  • Memory-safe communication between host and guest
  • Resource limits and security controls
  • Async plugin execution support

§Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Host (MoFA)                           │
│  ┌──────────────────────────────────────────────────────┐   │
│  │              WasmPluginRuntime                       │   │
│  │  ┌────────────┐  ┌────────────┐  ┌────────────┐     │   │
│  │  │  Engine    │  │   Linker   │  │   Store    │     │   │
│  │  └────────────┘  └────────────┘  └────────────┘     │   │
│  └──────────────────────────────────────────────────────┘   │
│                            │                                │
│  ┌──────────────────────────────────────────────────────┐   │
│  │              Host Functions                          │   │
│  │  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐        │   │
│  │  │  log   │ │ get_   │ │ send_  │ │ call_  │        │   │
│  │  │        │ │ config │ │ message│ │ tool   │        │   │
│  │  └────────┘ └────────┘ └────────┘ └────────┘        │   │
│  └──────────────────────────────────────────────────────┘   │
│                            │                                │
│  ┌──────────────────────────────────────────────────────┐   │
│  │              WASM Sandbox                            │   │
│  │  ┌─────────────────────────────────────────────┐     │   │
│  │  │            Plugin Instance                  │     │   │
│  │  │  ┌─────────┐  ┌─────────┐  ┌─────────┐     │     │   │
│  │  │  │ Memory  │  │ Exports │  │ Imports │     │     │   │
│  │  │  └─────────┘  └─────────┘  └─────────┘     │     │   │
│  │  └─────────────────────────────────────────────┘     │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

Re-exports§

pub use runtime::CompiledModule;
pub use runtime::ModuleCache;
pub use runtime::RuntimeConfig;
pub use runtime::RuntimeStats;
pub use runtime::WasmRuntime;

Modules§

runtime
WASM Runtime Core

Structs§

ExecutionConfig
Execution configuration
GuestPtr
Guest pointer type (32-bit address in WASM linear memory)
GuestSlice
Guest slice (pointer + length)
HostContext
Host context provided to plugins
LoadedPlugin
Loaded plugin information
MemoryAllocator
Memory allocator for managing guest memory
MemoryConfig
Memory configuration
MemoryRegion
Memory region descriptor
PluginExport
Plugin export definition
PluginHandle
Plugin handle for external reference
PluginInstance
Plugin instance wrapping wasmtime Instance
PluginManifest
Plugin manifest describing the plugin
PluginMetrics
Plugin execution metrics
PluginRegistry
Plugin registry for tracking loaded plugins
ResourceLimits
Resource limits for WASM execution
SharedMemoryBuffer
Shared memory buffer for inter-module communication
WasmMemory
WASM memory abstraction
WasmPlugin
WASM Plugin
WasmPluginConfig
WASM plugin configuration
WasmPluginManager
WASM Plugin Manager

Enums§

LogLevel
Log level for plugin logging
MessageDirection
Message direction
PluginCapability
Plugin capabilities
PluginEvent
Plugin event
WasmError
WASM runtime errors
WasmPluginState
WASM plugin state
WasmType
WASM type definitions
WasmValue
WASM value types

Traits§

HostFunctions
Host functions interface that plugins can call

Type Aliases§

HostCallback
Host callback for custom functions
WasmResult
WASM result type