pub struct Htl { /* private fields */ }Expand description
An mlua state with the Teal compiler loaded.
Implementations§
Source§impl Htl
impl Htl
Sourcepub fn apply_project(&self, p: &Project) -> Result<()>
pub fn apply_project(&self, p: &Project) -> Result<()>
Make the project’s vendored deps visible to the Teal checker and to the
prelude’s strict searcher (htl run / htl test without a Registry).
Source§impl Htl
impl Htl
Sourcepub fn install_test_lib(&self) -> Result<()>
pub fn install_test_lib(&self) -> Result<()>
Make require("htl.test") work at runtime and its types visible to the checker.
Source§impl Htl
impl Htl
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
New state. Uses Lua::unsafe_new so stripped bytecode bundles can be loaded.
Sourcepub fn from_lua(lua: Lua) -> Result<Self>
pub fn from_lua(lua: Lua) -> Result<Self>
Attach the Teal compiler to an existing Lua state (the host’s own Lua).
pub fn lua(&self) -> &Lua
Sourcepub fn gen_lua(&self, file: &Path) -> Result<(Option<String>, CheckInfo)>
pub fn gen_lua(&self, file: &Path) -> Result<(Option<String>, CheckInfo)>
Type-check and generate Lua source. None code means errors (see CheckInfo).
Sourcepub fn configure_lints(&self, spec: &str) -> Result<()>
pub fn configure_lints(&self, spec: &str) -> Result<()>
Configure lint rules: "+no-any,-shadow-local" on top of the defaults.
Sourcepub fn lint_rules(&self) -> Result<Vec<String>>
pub fn lint_rules(&self) -> Result<Vec<String>>
Names of all lint rules (enabled or not).
Sourcepub fn format_file(&self, file: &Path, indent: usize) -> Result<String>
pub fn format_file(&self, file: &Path, indent: usize) -> Result<String>
Format a .tl file (whitespace-only formatter). Returns the formatted text.
Sourcepub fn add_path(&self, dir: &Path) -> Result<()>
pub fn add_path(&self, dir: &Path) -> Result<()>
Prepend dir/?.tl;dir/?/init.tl to package.path (Teal resolves requires through it).
Sourcepub fn install_searcher(&self) -> Result<()>
pub fn install_searcher(&self) -> Result<()>
Install the strict .tl searcher: require of a .tl with type errors fails.
Sourcepub fn preload(&self, name: &str, lua_src: &str) -> Result<()>
pub fn preload(&self, name: &str, lua_src: &str) -> Result<()>
Register generated Lua source under a module name (package.preload).
Sourcepub fn preload_bytes(&self, name: &str, bytecode: &[u8]) -> Result<()>
pub fn preload_bytes(&self, name: &str, bytecode: &[u8]) -> Result<()>
Register stripped bytecode (e.g. from include_tl_bytes!) under a module name.
Sourcepub fn exec_bytes(
&self,
bytecode: &[u8],
chunk_name: &str,
args: &[String],
) -> Result<()>
pub fn exec_bytes( &self, bytecode: &[u8], chunk_name: &str, args: &[String], ) -> Result<()>
Execute stripped bytecode with ... = args.
Sourcepub fn preload_value(&self, name: &str, value: impl IntoLua) -> Result<()>
pub fn preload_value(&self, name: &str, value: impl IntoLua) -> Result<()>
Register a ready-made value (typically a Rust-built table) as a module.
Sourcepub fn set_arg(&self, script: &str, args: &[String]) -> Result<()>
pub fn set_arg(&self, script: &str, args: &[String]) -> Result<()>
Set the global arg table like the lua CLI does.
Sourcepub fn exec(
&self,
lua_src: &str,
chunk_name: &str,
args: &[String],
) -> Result<()>
pub fn exec( &self, lua_src: &str, chunk_name: &str, args: &[String], ) -> Result<()>
Execute Lua source with ... = args.
Sourcepub fn run_file(&self, file: &Path, args: &[String]) -> Result<CheckInfo>
pub fn run_file(&self, file: &Path, args: &[String]) -> Result<CheckInfo>
Check + gen + run a .tl script. If the check fails the script is not run and the
returned CheckInfo carries the errors. Runtime errors come back as Err.
Sourcepub fn compile(&self, name: &str, lua_src: &str) -> Result<Vec<u8>>
pub fn compile(&self, name: &str, lua_src: &str) -> Result<Vec<u8>>
Compile Lua source to stripped bytecode (Lua 5.4 format of this build).
Sourcepub fn install_bundle(&self, b: &Bundle) -> Result<()>
pub fn install_bundle(&self, b: &Bundle) -> Result<()>
Install a searcher serving modules from a bundle.
Auto Trait Implementations§
impl !Freeze for Htl
impl !RefUnwindSafe for Htl
impl !Send for Htl
impl !Sync for Htl
impl !UnwindSafe for Htl
impl Unpin for Htl
impl UnsafeUnpin for Htl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more