use airsl::{Engine, Policy, Script};
const GREETING: &str = r#"return "hello from Lua " .. _VERSION"#;
const SUM: &str = "local total = 0 for i = 1, 10 do total = total + i end return total";
fn main() -> Result<(), airsl::Error> {
let engine = Engine::builder().policy(Policy::confined()).build()?;
let greeting = Script::from_source(GREETING, "greeting")?;
println!("{}", engine.eval_to::<String>(&greeting)?);
let sum = Script::from_source(SUM, "sum")?;
println!("1..10 sums to {}", engine.eval_to::<i64>(&sum)?);
engine.eval(&greeting)?;
println!(
"surface: {}, grants: {}",
engine.policy().language(),
engine.policy().grants()
);
Ok(())
}