//! Demonstrates how to use the Rhai wrappers for our models use herodb::zaz::rhai::{run_script_file, run_example_script}; use std::path::PathBuf; use std::fs; use std::time::SystemTime; fn main() -> Result<(), String> { println!("=== RHAI MODEL WRAPPERS DEMONSTRATION ==="); // Run our test script that creates model objects let test_script_path = "src/zaz/rhai/test.rhai"; println!("\n1. Running model creation test script: {}", test_script_path); run_script_file(test_script_path)?; // Create temporary directory for DB example let temp_dir = create_temp_dir() .map_err(|e| format!("Failed to create temp dir: {}", e))?; // Run our example script that uses the DB println!("\n2. Running example with database at: {:?}", temp_dir); run_example_script(temp_dir.to_str().unwrap())?; println!("\n=== DEMONSTRATION COMPLETED SUCCESSFULLY ==="); Ok(()) } /// Creates a simple temporary directory fn create_temp_dir() -> std::io::Result { let temp_dir = std::env::temp_dir(); let random_name = format!("rhai-demo-{}", SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_millis()); let path = temp_dir.join(random_name); fs::create_dir_all(&path)?; Ok(path) }