pub trait RhaiAnalyzerExt {
// Required method
fn analyze(&self) -> ScriptAnalysisResult;
// Provided methods
fn accessed_variables(&self) -> HashSet<String> { ... }
fn string_comparisons_for(&self, variable_path: &str) -> HashSet<String> { ... }
}Expand description
Extension trait that adds static analysis capabilities directly to
rhai::AST.
Import this trait to call the analysis methods on any compiled Rhai AST:
use rhai::Engine;
use rhai_analyzer::RhaiAnalyzerExt;
let engine = Engine::new();
let ast = engine.compile(r#"if user.balance > 100 { send_alert(user.email); }"#).unwrap();
let vars = ast.accessed_variables();
assert!(vars.contains("user.balance"));
assert!(vars.contains("user.email"));Required Methods§
Sourcefn analyze(&self) -> ScriptAnalysisResult
fn analyze(&self) -> ScriptAnalysisResult
Returns the full ScriptAnalysisResult for the script.
Provided Methods§
Sourcefn accessed_variables(&self) -> HashSet<String>
fn accessed_variables(&self) -> HashSet<String>
Returns all unique, fully-qualified variable paths accessed by the
script (e.g. "tx.value", "log.name").
Sourcefn string_comparisons_for(&self, variable_path: &str) -> HashSet<String>
fn string_comparisons_for(&self, variable_path: &str) -> HashSet<String>
Returns the set of string literals that variable_path is compared
against (via == or !=) anywhere in the script.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".