Skip to main content

mofa_plugins/wasm_runtime/
mod.rs

1//! WASM Plugin Runtime Module
2//!
3//! Provides WebAssembly-based plugin execution for MoFA:
4//! - Sandboxed plugin execution
5//! - Host function interface for plugins
6//! - Memory-safe communication between host and guest
7//! - Resource limits and security controls
8//! - Async plugin execution support
9//!
10//! # Architecture
11//!
12//! ```text
13//! ┌─────────────────────────────────────────────────────────────┐
14//! │                      Host (MoFA)                           │
15//! │  ┌──────────────────────────────────────────────────────┐   │
16//! │  │              WasmPluginRuntime                       │   │
17//! │  │  ┌────────────┐  ┌────────────┐  ┌────────────┐     │   │
18//! │  │  │  Engine    │  │   Linker   │  │   Store    │     │   │
19//! │  │  └────────────┘  └────────────┘  └────────────┘     │   │
20//! │  └──────────────────────────────────────────────────────┘   │
21//! │                            │                                │
22//! │  ┌──────────────────────────────────────────────────────┐   │
23//! │  │              Host Functions                          │   │
24//! │  │  ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐        │   │
25//! │  │  │  log   │ │ get_   │ │ send_  │ │ call_  │        │   │
26//! │  │  │        │ │ config │ │ message│ │ tool   │        │   │
27//! │  │  └────────┘ └────────┘ └────────┘ └────────┘        │   │
28//! │  └──────────────────────────────────────────────────────┘   │
29//! │                            │                                │
30//! │  ┌──────────────────────────────────────────────────────┐   │
31//! │  │              WASM Sandbox                            │   │
32//! │  │  ┌─────────────────────────────────────────────┐     │   │
33//! │  │  │            Plugin Instance                  │     │   │
34//! │  │  │  ┌─────────┐  ┌─────────┐  ┌─────────┐     │     │   │
35//! │  │  │  │ Memory  │  │ Exports │  │ Imports │     │     │   │
36//! │  │  │  └─────────┘  └─────────┘  └─────────┘     │     │   │
37//! │  │  └─────────────────────────────────────────────┘     │   │
38//! │  └──────────────────────────────────────────────────────┘   │
39//! └─────────────────────────────────────────────────────────────┘
40//! ```
41
42mod host;
43mod manager;
44mod memory;
45mod plugin;
46pub mod runtime;
47mod types;
48
49pub use host::{HostCallback, HostContext, HostFunctions, LogLevel, MessageDirection};
50pub use manager::{LoadedPlugin, PluginEvent, PluginHandle, PluginRegistry, WasmPluginManager};
51pub use memory::{
52    GuestPtr, GuestSlice, MemoryAllocator, MemoryRegion, SharedMemoryBuffer, WasmMemory,
53};
54pub use plugin::{PluginInstance, PluginMetrics, WasmPlugin, WasmPluginConfig, WasmPluginState};
55pub use runtime::{CompiledModule, ModuleCache, RuntimeConfig, RuntimeStats, WasmRuntime};
56pub use types::{
57    ExecutionConfig, MemoryConfig, PluginCapability, PluginExport, PluginManifest, ResourceLimits,
58    WasmError, WasmResult, WasmType, WasmValue,
59};