2 releases
Uses new Rust 2024
| new 0.1.1 | Jan 11, 2026 |
|---|---|
| 0.1.0 | Jan 11, 2026 |
#2069 in WebAssembly
Used in 2 crates
(via aegis-wasm)
150KB
3K
SLoC
Aegis Host Function System
This crate provides the host function system for the Aegis WebAssembly sandbox runtime. It includes:
AegisLinker: Safe wrapper around Wasmtime's LinkerHostContext: Context available to host function implementations- Capability-aware function registration
Host Functions
Host functions are the bridge between guest WASM code and the host system. Aegis requires all host functions to be registered with their capability requirements, ensuring that guests can only call functions they have permission to use.
Example
use aegis_host::{AegisLinker, HostContext, IntoHostContext};
use aegis_capability::CapabilityId;
let mut linker = AegisLinker::new(&engine);
// Register a host function that requires the logging capability
linker.func_wrap_with_capability(
"env",
"log",
Some(CapabilityId::new("logging")),
|caller: wasmtime::Caller<'_, MyState>, msg_ptr: i32, msg_len: i32| {
let mut ctx = caller.into_context();
let message = ctx.read_string_with_len(msg_ptr as usize, msg_len as usize)?;
println!("Guest log: {}", message);
Ok(())
},
)?;
aegis-host
Host function system for the Aegis WebAssembly sandbox.
This crate provides:
AegisLinker- Safe wrapper around Wasmtime's linkerHostContext- Context available to host functions- Automatic capability checks for host function calls
Usage
This is an internal crate. Use aegis-wasm for the public API.
[dependencies]
aegis-wasm = "0.1"
License
MIT OR Apache-2.0
Dependencies
~26MB
~395K SLoC