forked from StrafesNET/strafe-project
20 lines
358 B
Rust
20 lines
358 B
Rust
|
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(())
|
||
|
}
|
||
|
}
|