mlua-lshape 0.1.0

mlua wrapper for lshape — Schema-as-Data validator + LuaCATS codegen, Pure Lua vendored via include_str!.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 2 items with examples
  • Size
  • Source code size: 73.39 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 316.97 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 4s Average build duration of successful builds.
  • all releases: 1m 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ynishi/mlua-lshape
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ynishi

mlua-lshape

mlua wrapper for lshape — Pure Lua Schema-as-Data validator + LuaCATS codegen. The lshape/*.lua sources are vendored into this crate (under lua/lshape/) and embedded via include_str! at compile time.

Quick start

use mlua::Lua;
use mlua_lshape::install;

let lua = Lua::new();
install(&lua)?;
lua.load(r#"
    local lshape = require("lshape")
    local T = lshape.t
    local Voted = T.shape({ answer = T.string, reasoning = T.string })
    local ok, why = lshape.check.check({ answer = "42", reasoning = "..." }, Voted)
    assert(ok, why)
"#).exec()?;

Why vendored?

The upstream lshape is Pure Lua with no package manager dependency. Shipping the sources inside this crate keeps downstream builds hermetic — no LuaRocks, no filesystem probing, no version drift. The same pattern is used by mlua-probe-mcp / mlua-lspec.

Vendored sources

lua/lshape/*.lua is a verbatim copy of the upstream ynishi/lshape repository, pinned to v0.1.0. See CHANGELOG.md for the embedded surface. Refresh via:

cp /path/to/lshape/lshape/*.lua lua/lshape/

The LSHAPE_SOURCES public constant exposes the embedded sources (&[(name, src)]) for downstream consumers that want to inject them into another Lua VM or hash them for drift checks.

Lua version

This crate pins mlua to lua54 + vendored, matching the sibling mlua-* crates (mlua-probe, mlua-lspec, mlua-check). Other Lua versions are not currently supported.

License

MIT OR Apache-2.0. The vendored lua/lshape/ files are dual-licensed under the same terms, copyright Yutaka Nishimura.