Skip to main content

Crate htl_core

Crate htl_core 

Source
Expand description

htl: Teal, hidden.

Embeds the Teal compiler (tl.lua) into an mlua state so .tl sources can be type-checked, generated and executed without any external toolchain.

  • Htl::check / [Htl::gen]: type-check and generate Lua from a .tl file
  • Htl::install_searcher: strict require for .tl (type errors abort the require)
  • Htl::preload: register generated Lua (e.g. from include_tl!) under a module name
  • bundle: stripped-bytecode bundles produced by htl build

Re-exports§

pub use mlua;

Modules§

bundle
Bundle format (.hb): one program’s modules in a single file.
config
htl.toml: project-level settings shared by the CLI and include_tl!.
link
Linking: the require closure of one entry file, as a Bundle.
pkg
mlua-pkg integration: a TealResolver that serves .tl modules through mlua-pkg’s Registry, so Teal sources sit in the same resolution chain as Rust-native modules, embedded Lua, vendored git deps and assets.
teal
Rust <-> Teal type bridge used by #[derive(TealRecord)] and #[host_module].
testing
htl test: discovery, one isolated Lua state per test file, compile, report.

Structs§

CheckInfo
Result of type-checking one .tl file.
ContractResult
Result of a static contract check (see Htl::contract_check).
Htl
An mlua state with the Teal compiler loaded.
RequireSite
One literal require call in a checked file.

Constants§

SKIP_DIRS
Directories never descended into when collecting sources under a root: build output, installed packages, VCS and tool state. A root passed explicitly is always walked.
TEAL_VERSION
Teal version vendored into this crate.

Functions§

collect_tl
Collect .tl sources from files and directories (sorted, recursive). Directories in SKIP_DIRS, dot-directories and the project’s package dir are not entered unless given as a root themselves.
contract_enforcement_lints
contract-unenforced lint: a [[contract]] in htl.toml only becomes a run-time guarantee when the host builds its resolver with it. Scan the host crate’s Rust sources (under cargo_root) for expect_type("<type>") (plus require_fields() when required) or for the config-driven contract_resolvers( / for_contract( helpers. No host crate (cargo_root = None) means a script-only project: nothing to enforce.
contract_lints
contract lint for one file: when file sits directly under a [[contract]] dir of cfg (relative to root, the directory holding htl.toml), check it against that contract statically. Returns lint lines (empty when no contract applies).
is_skipped_dir
true for a directory entry that source collection should not enter: a name in SKIP_DIRS, any dot-directory, or the project’s mlua-pkg directory (pkgs_dir, which MLUA_PKG_DIR can move somewhere unremarkable).
is_tl_source
true for foo.tl but not foo.d.tl.
module_name
root/foo/bar.tl -> foo.bar, root/foo/init.tl -> foo.
parent_dir
Parent directory of a file, . when the path has none.
project_skip_dirs
Extra directories to skip below root: the mlua-pkg package dir when root is inside an mlua-pkg.toml project (its vendored / cached sources are dependencies, not the project’s own files).
require_cycles
Cycles in the require graph of a set of checked files, one message per cycle, anchored at the first edge’s call site. Teal types a circular require as an opaque circular_require, so a cycle shows up elsewhere as “cannot index” errors; naming the loop is the useful part. Files outside infos are treated as leaves.
strip_traceback
Remove a trailing Lua stack traceback: section from an error text.
user_message
A user-facing message for an error that came out of running Lua: the innermost cause without Lua’s stack traceback: block. A host function’s Err(e) surfaces as e’s own text; a Lua error("msg") surfaces as file:line: msg.
write_if_changed
Write text to path only if the content differs. Returns true when written. Used by the derive macros to emit .d.tl files without churning cargo’s fingerprints.