vibelang_rhai/lib.rs
1//! VibeLang Rhai - Scripting layer for VibeLang.
2//!
3//! This crate provides the Rhai scripting API for VibeLang, allowing users to write
4//! `.vibe` scripts that define musical compositions.
5//!
6//! # Architecture
7//!
8//! The scripting layer works by:
9//! 1. Executing a Rhai script that calls builder APIs (voice(), pattern(), etc.)
10//! 2. These builders collect their configuration into a thread-local ScriptState
11//! 3. After execution, the ScriptState is applied to the Runtime via the reload system
12//!
13//! # Example
14//!
15//! ```ignore
16//! use vibelang_rhai::ScriptEngine;
17//! use vibelang_core::Runtime;
18//!
19//! let backend = /* create backend */;
20//! let runtime = Runtime::new(backend).await?;
21//! let mut engine = ScriptEngine::new(runtime.handle());
22//!
23//! engine.execute_file("song.vibe").await?;
24//! ```
25
26pub mod api;
27pub mod context;
28pub mod engine;
29pub mod error;
30
31// Optional extensions module (feature-gated)
32#[cfg(any(feature = "ext-fs", feature = "ext-exec", feature = "ext-net"))]
33pub mod extensions;
34
35// Re-exports
36pub use engine::ScriptEngine;
37pub use error::{Error, Result};
38
39// Exit code handling for integration tests
40pub use api::assert::{get_exit_code, reset_exit_code};
41
42// Re-export extension config when any extension is enabled
43#[cfg(any(feature = "ext-fs", feature = "ext-exec", feature = "ext-net"))]
44pub use extensions::ExtensionConfig;