torvyn_engine/lib.rs
1//! # torvyn-engine
2//!
3//! Wasm engine abstraction and component invocation layer for the
4//! Torvyn reactive streaming runtime.
5//!
6//! This crate provides:
7//! - [`WasmEngine`] — abstract interface for Wasm runtime operations
8//! (compile, instantiate, fuel/memory management).
9//! - [`ComponentInvoker`] — the hot-path typed invocation interface
10//! between the reactor and Wasm execution (**Gap G-01 fix**).
11//! - [`WasmtimeEngine`] — Wasmtime-based `WasmEngine` implementation
12//! (feature: `wasmtime-backend`).
13//! - [`WasmtimeInvoker`] — Wasmtime-based `ComponentInvoker` implementation
14//! (feature: `wasmtime-backend`).
15//! - [`CompiledComponentCache`] — compiled component cache with disk support.
16//! - Mock implementations for testing downstream crates (feature: `mock`).
17//!
18//! # Feature Flags
19//! - `wasmtime-backend` (default) — enables the Wasmtime backend.
20//! - `mock` — enables mock implementations for testing.
21//! - `tracing-support` — enables structured logging via the `tracing` crate.
22//!
23//! # Architecture
24//! Per Doc 02, Section 3: all Wasm engine interactions go through the
25//! `WasmEngine` trait to insulate Torvyn from Wasmtime-specific APIs.
26//! The `ComponentInvoker` trait (Doc 10, Gap G-01) provides typed
27//! hot-path invocation between the reactor and Wasm execution.
28
29#![deny(missing_docs)]
30
31pub mod config;
32pub mod error;
33pub mod traits;
34pub mod types;
35
36#[cfg(feature = "wasmtime-backend")]
37pub mod wasmtime_engine;
38
39#[cfg(feature = "wasmtime-backend")]
40pub mod wasmtime_invoker;
41
42pub mod cache;
43
44#[cfg(feature = "mock")]
45pub mod mock;
46
47// ---------------------------------------------------------------------------
48// Re-exports
49// ---------------------------------------------------------------------------
50
51pub use cache::CompiledComponentCache;
52pub use config::{CompilationStrategy, WasmtimeEngineConfig};
53pub use error::EngineError;
54pub use traits::{ComponentInvoker, WasmEngine};
55pub use types::{
56 CompiledComponent, ComponentInstance, ImportBindings, InvocationResult, OutputElement,
57 ProcessResult, StreamElement,
58};
59
60#[cfg(feature = "wasmtime-backend")]
61pub use wasmtime_engine::WasmtimeEngine;
62
63#[cfg(feature = "wasmtime-backend")]
64pub use wasmtime_invoker::WasmtimeInvoker;