Crate fusabi_host

Crate fusabi_host 

Source
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 helpers
  • async-runtime-tokio: Async execution support via Tokio
  • async-runtime-async-std: Async execution support via async-std
  • metrics-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.
CompileOptions
Options for compilation.
CompileResult
Result of compilation.
Engine
A Fusabi execution engine.
EngineConfig
Configuration for creating an Engine.
EnginePool
A pool of Fusabi engines for concurrent execution.
ExecutionContext
Execution context passed to host functions.
HostRegistry
Host function registry.
Limits
Resource limits for script execution.
Metadata
Metadata extracted from compiled bytecode.
PoolConfig
Configuration for an engine pool.
PoolHandle
A handle to a pooled engine.
PoolStats
Statistics about pool usage.
Sandbox
A sandbox instance that enforces security policies during execution.
SandboxConfig
Configuration for the sandbox environment.

Enums§

Capability
Individual capability that can be granted to scripts.
Error
Errors that can occur during Fusabi host operations.
LimitViolation
A violation of resource limits.
NetPolicy
Policy for network access.
PathPolicy
Policy for filesystem path access.
Value
A Fusabi runtime value.
ValueConversionError
Error that occurs during value conversion.
ValueType
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§

FromValue
Trait for types that can be created from a Value.
IntoValue
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.

Type Aliases§

HostFn
Host function signature.
Result
Result type alias using [Error].