refactor: Move module load code into separate function
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(iterator_try_collect)]
|
||||
|
||||
use tracing::debug;
|
||||
|
||||
pub mod action_callback;
|
||||
pub mod config;
|
||||
pub mod device;
|
||||
@@ -34,4 +36,15 @@ impl Module {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_modules(lua: &mlua::Lua) -> mlua::Result<()> {
|
||||
debug!("Loading modules...");
|
||||
for module in inventory::iter::<Module> {
|
||||
debug!(name = module.get_name(), "Registering");
|
||||
let table = module.register(lua)?;
|
||||
lua.register_module(module.get_name(), table)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
inventory::collect!(Module);
|
||||
|
||||
Reference in New Issue
Block a user