Expand description
§fusabi-host
Shared host/runtime utilities for Fusabi across Scarab, Tolaria, Hibana, and Phage.
This crate provides:
- Engine pools for concurrent Fusabi execution with thread-safe access
- Value conversion helpers for seamless Value↔Serde transformations
- Typed host function macros for ergonomic host function registration
- Sandbox and capability configuration for secure script execution
- Stable compile/run APIs for consistent host integration
§Quick Start
ⓘ
use fusabi_host::{EnginePool, PoolConfig, Capabilities, Limits};
// Create a pool with 4 engines
let config = PoolConfig::new(4)
.with_limits(Limits::default())
.with_capabilities(Capabilities::none());
let pool = EnginePool::new(config)?;
// Execute a script
let result = pool.execute("1 + 2")?;§Feature Flags
serde-support(default): Enable Value↔Serde conversion helpersasync-runtime-tokio: Async execution support via Tokioasync-runtime-async-std: Async execution support via async-stdmetrics-prometheus: Prometheus metrics integration
Macros§
- extract_
field - Helper macro to extract a required field from a map Value.
- extract_
field_ opt - Helper macro to extract an optional field from a map Value.
- host_fn
- Macro to define a typed host function.
Structs§
- Capabilities
- A set of capabilities granted to a script.
- Compile
Options - Options for compilation.
- Compile
Result - Result of compilation.
- Engine
- A Fusabi execution engine.
- Engine
Config - Configuration for creating an Engine.
- Engine
Pool - A pool of Fusabi engines for concurrent execution.
- Execution
Context - Execution context passed to host functions.
- Host
Registry - Host function registry.
- Limits
- Resource limits for script execution.
- Metadata
- Metadata extracted from compiled bytecode.
- Pool
Config - Configuration for an engine pool.
- Pool
Handle - A handle to a pooled engine.
- Pool
Stats - Statistics about pool usage.
- Sandbox
- A sandbox instance that enforces security policies during execution.
- Sandbox
Config - Configuration for the sandbox environment.
Enums§
- Capability
- Individual capability that can be granted to scripts.
- Error
- Errors that can occur during Fusabi host operations.
- Limit
Violation - A violation of resource limits.
- NetPolicy
- Policy for network access.
- Path
Policy - Policy for filesystem path access.
- Value
- A Fusabi runtime value.
- Value
Conversion Error - Error that occurs during value conversion.
- Value
Type - The type of a Fusabi value.
Constants§
- MAX_
FUSABI_ VERSION - Maximum supported Fusabi version
- MIN_
FUSABI_ VERSION - Minimum supported Fusabi version (LTS alignment)
- VERSION
- Crate version for compatibility checks
Traits§
- From
Value - Trait for types that can be created from a
Value. - Into
Value - Trait for types that can be converted into a
Value.
Functions§
- compile_
file - Compile a Fusabi source file to bytecode.
- compile_
source - Compile Fusabi source code to bytecode.
- from_
value_ serde - Deserialize a Value into a type implementing DeserializeOwned.
- is_
compatible_ version - Check if a Fusabi version is compatible with this host runtime
- to_
value_ serde - Serialize a type implementing Serialize into a Value.
- typed_
host_ fn_ 2 - Typed host function with 2 arguments.
- validate_
bytecode - Validate bytecode without executing.