Lua 5.4 implementation of the Twilic wire format and session-aware encoder/decoder.
This module's default Twilic.encode / Twilic.decode API targets Twilic v2. Stateful protocol features use new_twilic_codec() and new_session_encoder().
twilic-lua/
src/twilic/init.lua # public API
src/twilic/core/ # wire, model, codec, session, protocol, v2
spec/ # busted tests (ported from twilic-ruby)
bin/ # Rust interop CLI scripts
scripts/ # interop smoke checks
- Lua 5.4
- LuaRocks (for
bustedin development)
luarocks install twilic-3.0.0-1.rockspecOr use the tree directly by setting LUA_PATH:
export LUA_PATH="$(pwd)/src/?.lua;$(pwd)/src/?/init.lua;;"local twilic = require("twilic")
local value = twilic.map({
id = twilic.u64(1001),
name = twilic.string("alice"),
})
local bytes = twilic.encode(value)
local decoded = twilic.decode(bytes)
print(twilic.equal(decoded, value)) -- truelocal twilic = require("twilic")
local enc = twilic.new_session_encoder()
local value = twilic.map({
id = twilic.u64(1),
role = twilic.string("admin"),
})
local bytes = enc:encode(value)luarocks install busted
export LUA_PATH="src/?.lua;src/?/init.lua;;"
busted specRust interop (requires cargo and optional sibling twilic-rust):
bash scripts/check-interop.shThis project is licensed under the MIT License - see the LICENSE file for details.