This commit is contained in:
2025-04-04 15:21:45 +02:00
parent eecbed4b1f
commit 071dee514a
8 changed files with 547 additions and 0 deletions

43
src/rhai/mod.rs Normal file
View File

@@ -0,0 +1,43 @@
//! Rhai scripting integration for the SAL library
//!
//! This module provides integration with the Rhai scripting language,
//! allowing SAL functions to be called from Rhai scripts.
mod error;
mod os;
#[cfg(test)]
mod tests;
use rhai::Engine;
pub use error::*;
pub use os::*;
/// Register all SAL modules with the Rhai engine
///
/// # Arguments
///
/// * `engine` - The Rhai engine to register the modules with
///
/// # Example
///
/// ```
/// use rhai::Engine;
/// use sal::rhai;
///
/// let mut engine = Engine::new();
/// rhai::register(&mut engine);
///
/// // Now you can use SAL functions in Rhai scripts
/// let result = engine.eval::<bool>("exist('some_file.txt')").unwrap();
/// ```
pub fn register(engine: &mut Engine) -> Result<(), Box<rhai::EvalAltResult>> {
// Register OS module functions
os::register_os_module(engine)?;
// Future modules can be registered here
// e.g., process::register_process_module(engine)?;
Ok(())
}