//! 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; mod process; mod buildah; mod nerdctl; mod git; #[cfg(test)] mod tests; // Re-export common Rhai types for convenience pub use rhai::{Array, Dynamic, Map, EvalAltResult, Engine}; // Re-export error module pub use error::*; // Re-export specific functions from modules to avoid name conflicts pub use os::{ register_os_module, // File system functions exist, find_file, find_files, find_dir, find_dirs, delete, mkdir, file_size, rsync, // Download functions download, download_install }; pub use process::{ register_process_module, // Run functions run, run_silent, run_with_options, new_run_options, // Process management functions which, kill, process_list, process_get }; // Re-export buildah functions pub use buildah::register_bah_module; pub use buildah::bah_new; // Re-export nerdctl functions pub use nerdctl::register_nerdctl_module; pub use nerdctl::{ // Container functions nerdctl_run, nerdctl_run_with_name, nerdctl_run_with_port, nerdctl_exec, nerdctl_copy, nerdctl_stop, nerdctl_remove, nerdctl_list, // Image functions nerdctl_images, nerdctl_image_remove, nerdctl_image_push, nerdctl_image_tag, nerdctl_image_pull, nerdctl_image_commit, nerdctl_image_build }; // Re-export git module pub use git::register_git_module; pub use crate::git::{GitTree, GitRepo}; // Rename copy functions to avoid conflicts pub use os::copy as os_copy; /// 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::("exist('some_file.txt')").unwrap(); /// ``` pub fn register(engine: &mut Engine) -> Result<(), Box> { // Register OS module functions os::register_os_module(engine)?; // Register Process module functions process::register_process_module(engine)?; // Register Buildah module functions buildah::register_bah_module(engine)?; // Register Nerdctl module functions nerdctl::register_nerdctl_module(engine)?; // Register Git module functions git::register_git_module(engine)?; // Future modules can be registered here Ok(()) }