Expand description
Runtime host functions available to plugins.
This module provides the interface for WASM plugins to interact with the Orbis runtime. These functions are imported by plugins and implemented by the host runtime.
§Memory Management
Plugins must implement two functions for memory management:
#[unsafe(no_mangle)]
pub extern "C" fn allocate(size: i32) -> *mut u8 {
let mut buf = Vec::with_capacity(size as usize);
let ptr = buf.as_mut_ptr();
std::mem::forget(buf);
ptr
}
#[unsafe(no_mangle)]
pub extern "C" fn deallocate(ptr: *mut u8, size: i32) {
unsafe {
let _ = Vec::from_raw_parts(ptr, 0, size as usize);
}
}§Handler Functions
Plugin handlers receive a pointer and length to JSON-serialized context data, and must return a pointer to JSON-serialized response data:
#[unsafe(no_mangle)]
pub extern "C" fn my_handler(context_ptr: i32, context_len: i32) -> i32 {
// Read context from memory
// Process request
// Return pointer to response (with length prefix)
0 // placeholder
}Response format: [4 bytes length (u32 le)] [data bytes]
Modules§
- helpers
- Helper utilities for plugin development.
Structs§
- Host
Functions - Host functions that plugins can import and call.
- Plugin
Context - Context passed to plugin handlers.
Enums§
- LogLevel
- Log levels for plugin logging.