Expand description
lshape exporter for schema-bridge.
Turns the schema-bridge Schema IR into lshape
type definitions — a Lua module built from T.shape / T.array_of /
T.one_of combinators that can be loaded and used with lshape.check.check.
use schema_bridge_core::{Field, Schema};
use schema_bridge_lshape::generate_lshape_file;
let user = Schema::Object(vec![
Field::new("name", Schema::String),
Field::optional("email", Schema::String),
]);
let lua_src = generate_lshape_file(&[("User", user)]).unwrap();
assert!(lua_src.contains("M.User = T.shape({"));§lshape version requirement
Generated modules use T.integer / T.tuple / the bounds combinators
(:min / :max / :min_len / :max_len), which require
lshape 0.3.0+ at load time (vendored by mlua-lshape 0.3+).
Semantic note: lshape’s T.integer is the portable whole-number check
(v % 1 == 0), so 2.0 passes; Rust-side integer range (e.g. u8)
is not carried into the schema.
Macros§
- export_
lshape_ types - Export types (anything deriving
SchemaBridge) to an lshape Lua module.
Enums§
- Export
Error - Error produced by
export_to_lua_file. - Lshape
Error - Error produced while mapping a
Schemato lshape source text.
Functions§
- export_
to_ lua_ file - Generate the lshape module for
typesand write it topath. - generate_
lshape_ file - Generate a complete Lua module defining one lshape schema per entry.
- schema_
to_ lshape - Convert a single
Schemainto an lshape expression such asT.shape({ name = T.string }).