feat(lua): expose hash fn

This commit is contained in:
əlemi 2024-08-14 17:16:58 +02:00
parent c58d1db58b
commit 8806941a13
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -269,6 +269,10 @@ fn get_logger(_: &Lua, (): ()) -> LuaResult<LuaLogger> {
Ok(LuaLogger(sub)) Ok(LuaLogger(sub))
} }
fn hash(_: &Lua, (txt,): (String,)) -> LuaResult<i64> {
Ok(crate::hash(txt))
}
// define module and exports // define module and exports
#[mlua::lua_module] #[mlua::lua_module]
fn codemp_lua(lua: &Lua) -> LuaResult<LuaTable> { fn codemp_lua(lua: &Lua) -> LuaResult<LuaTable> {
@ -279,6 +283,9 @@ fn codemp_lua(lua: &Lua) -> LuaResult<LuaTable> {
exports.set("get_client", lua.create_function(get_client)?)?; exports.set("get_client", lua.create_function(get_client)?)?;
exports.set("close_client", lua.create_function(close_client)?)?; exports.set("close_client", lua.create_function(close_client)?)?;
// utils
exports.set("hash", lua.create_function(hash)?)?;
// runtime // runtime
exports.set("runtime_drive_forever", lua.create_function(runtime_drive_forever)?)?; exports.set("runtime_drive_forever", lua.create_function(runtime_drive_forever)?)?;