runner: no object
This commit is contained in:
parent
4eb6c7c057
commit
2ccc5bb17d
@ -1,3 +1,3 @@
|
||||
mod runner;
|
||||
|
||||
pub use runner::{Runner,Error};
|
||||
pub use runner::{run,Error};
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user