Skip to main content

Crate mlua_lshape

Crate mlua_lshape 

Source
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 require path (e.g. "lshape"lua/lshape/init.lua), value is the file contents.

Functions§

install
Install the lshape.* modules into the given Lua state’s package.preload table. After this returns, Lua code can require("lshape") / require("lshape.t") / etc. normally.