From e50703fc779555909982254dec60173175a374f7 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 1 Sep 2024 03:11:43 +0200 Subject: [PATCH] chore(lua): module at the bottom --- src/ffi/lua.rs | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ffi/lua.rs b/src/ffi/lua.rs index 7bccb67..9539f7a 100644 --- a/src/ffi/lua.rs +++ b/src/ffi/lua.rs @@ -341,30 +341,6 @@ impl LuaUserData for CodempTextChange { } -// define module and exports -#[mlua::lua_module] -fn codemp_native(lua: &Lua) -> LuaResult { - let exports = lua.create_table()?; - - // entrypoint - exports.set("connect", lua.create_function(|_, (host, username, password):(String,String,String)| - a_sync! { => Ok(CodempClient::connect(host, username, password).await?) } - )?)?; - - // utils - exports.set("hash", lua.create_function(|_, (txt,):(String,)| - Ok(crate::hash(txt)) - )?)?; - - // runtime - exports.set("spawn_runtime_driver", lua.create_function(spawn_runtime_driver)?)?; - - // logging - exports.set("logger", lua.create_function(logger)?)?; - - Ok(exports) -} - #[derive(Debug, Clone)] struct LuaLoggerProducer(mpsc::UnboundedSender); @@ -455,3 +431,27 @@ fn logger(_: &Lua, (printer, debug): (LuaValue, Option)) -> LuaResult LuaResult { + let exports = lua.create_table()?; + + // entrypoint + exports.set("connect", lua.create_function(|_, (host, username, password):(String,String,String)| + a_sync! { => Ok(CodempClient::connect(host, username, password).await?) } + )?)?; + + // utils + exports.set("hash", lua.create_function(|_, (txt,):(String,)| + Ok(crate::hash(txt)) + )?)?; + + // runtime + exports.set("spawn_runtime_driver", lua.create_function(spawn_runtime_driver)?)?; + // logging + exports.set("logger", lua.create_function(logger)?)?; + + Ok(exports) +}