20 lines
358 B
Rust
Raw Normal View History

2024-09-16 18:54:04 -07:00
pub enum Error{
Lua(mlua::Error),
}
pub struct Runner{
source:String,
}
impl Runner{
pub const fn new(source:String)->Self{
Self{source}
}
pub fn run(self,context:&mut crate::context::Context)->Result<(),Error>{
let lua=mlua::Lua::new();
lua.sandbox(true).map_err(Error::Lua)?;
lua.load(self.source).exec().map_err(Error::Lua)?;
Ok(())
}
}