fusabi-host
Shared host/runtime utilities for Fusabi across Scarab, Tolaria, Hibana, and Phage.
Features
- Engine Pools - Thread-safe engine pooling for concurrent script execution
- Value Conversion - Seamless Value↔Serde transformation helpers
- Typed Host Functions - Ergonomic macros for host function registration
- Sandbox & Capabilities - Fine-grained security controls for untrusted code
- Stable Compile/Run APIs - Consistent interfaces for host integration
Quick Start
use ;
Feature Flags
| Feature | Description |
|---|---|
serde-support (default) |
Enable Value↔Serde conversion helpers |
async-runtime-tokio |
Async execution support via Tokio |
async-runtime-async-std |
Async execution support via async-std |
metrics-prometheus |
Prometheus metrics integration |
Safety Model
Capabilities
Scripts must be granted explicit capabilities for privileged operations:
use ;
// No capabilities (fully sandboxed)
let none = none;
// Safe defaults (time, random, stdout, logging)
let safe = safe_defaults;
// Full access (use with trusted code only)
let all = all;
// Custom capability set
let custom = none
.with
.with;
Resource Limits
Control resource consumption with configurable limits:
use Limits;
use Duration;
let limits = default
.with_timeout
.with_memory_mb
.with_max_instructions;
// Strict limits for untrusted code
let strict = strict;
// No limits (trusted code only)
let unlimited = unlimited;
Sandbox Configuration
Control filesystem and network access:
use ;
let sandbox = locked
.with_read_paths
.with_allowed_hosts;
Typed Host Functions
Register host functions with automatic argument conversion:
use ;
let mut engine = new?;
// Register a simple function
engine.registry_mut.register;
// Register with context access
engine.registry_mut.register;
Compilation API
Compile Fusabi source to bytecode:
use ;
// Compile source string
let result = compile_source?;
println!;
// Compile from file
let result = compile_file?;
// Access metadata
for export in &result.metadata.exports
Version Compatibility
This crate is aligned with Fusabi LTS releases:
| fusabi-host | Fusabi |
|---|---|
| 0.1.x | 0.18.x - 0.19.x |
See compat.md for detailed compatibility information.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.