mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
chore(lua): module at the bottom
This commit is contained in:
parent
89dbc89225
commit
e50703fc77
1 changed files with 24 additions and 24 deletions
|
@ -341,30 +341,6 @@ impl LuaUserData for CodempTextChange {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// define module and exports
|
|
||||||
#[mlua::lua_module]
|
|
||||||
fn codemp_native(lua: &Lua) -> LuaResult<LuaTable> {
|
|
||||||
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)]
|
#[derive(Debug, Clone)]
|
||||||
struct LuaLoggerProducer(mpsc::UnboundedSender<String>);
|
struct LuaLoggerProducer(mpsc::UnboundedSender<String>);
|
||||||
|
@ -455,3 +431,27 @@ fn logger(_: &Lua, (printer, debug): (LuaValue, Option<bool>)) -> LuaResult<bool
|
||||||
|
|
||||||
Ok(success)
|
Ok(success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// define module and exports
|
||||||
|
#[mlua::lua_module]
|
||||||
|
fn codemp_native(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue