Skip to main content

lshape_module_source

Function lshape_module_source 

Source
pub fn lshape_module_source() -> String
Expand description

The knl_types Lua module, as source text.

Generated from types::declared at every host start rather than checked in: a generated file in the tree is a file that can be edited, and one that has been edited is a second declaration wearing the first one’s name. The host adds it to the embedded module set (crate::host) so the Lua kernel can require("knl_types"), and knl.api().types hands back this same text for tooling that wants to read the surface without loading it.

schema_bridge_lshape::generate_lshape_file would do all of this in one call, except that it has no way to emit lshape’s strict mode (types::Strict::Closed) — so the module is assembled here from that crate’s per-schema renderer, in the same layout, and the two tables whose extra keys are violations get the option appended.

Built once per process. It is a pure function of types that are fixed at compile time, so the text it answers can only be one text; rendering every declared schema again on each call — the host’s start, every knl.api() — was work whose result was known. The OnceLock holds it and the call hands back a copy, which keeps the signature (and the caller that hands the source to Lua::load) exactly as it was.