runner: no object

This commit is contained in:
Quaternions 2024-09-16 19:01:16 -07:00
parent 4eb6c7c057
commit 2ccc5bb17d
3 changed files with 7 additions and 16 deletions

View File

@ -1,3 +1,3 @@
mod runner;
pub use runner::{Runner,Error};
pub use runner::{run,Error};

View File

@ -2,18 +2,9 @@ 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(())
}
pub fn run(source:String,context:&mut crate::context::Context)->Result<(),Error>{
let lua=mlua::Lua::new();
lua.sandbox(true).map_err(Error::Lua)?;
lua.load(source).exec().map_err(Error::Lua)?;
Ok(())
}

View File

@ -23,6 +23,6 @@ impl Script{
}
};
// run it lole
crate::runner::Runner::new(source).run(context).map_err(Error::Runner)
crate::runner::run(source,context).map_err(Error::Runner)
}
}