Expand description
mlua-lshape — mlua wrapper for lshape (Pure Lua Schema-as-Data
validator + LuaCATS codegen).
The five lshape/*.lua sources are vendored under lua/lshape/ and
embedded into the binary via include_str! at compile time, so
downstream crates get the full module tree without any runtime
filesystem dependency.
Typical use from Rust:
use mlua::Lua;
use mlua_lshape::install;
let lua = Lua::new();
install(&lua).unwrap();
let chunk = r#"
local lshape = require("lshape")
local T = lshape.t
local Voted = T.shape({ answer = T.string })
local ok, why = lshape.check.check({ answer = "42" }, Voted)
assert(ok, why)
"#;
lua.load(chunk).exec().unwrap();Constants§
- LSHAPE_
SOURCES - Embedded Lua source files. Key is the
requirepath (e.g."lshape"→lua/lshape/init.lua), value is the file contents.
Functions§
- install
- Install the
lshape.*modules into the given Lua state’spackage.preloadtable. After this returns, Lua code canrequire("lshape")/require("lshape.t")/ etc. normally.