Skip to main content

Htl

Struct Htl 

Source
pub struct Htl { /* private fields */ }
Expand description

An mlua state with the Teal compiler loaded.

Implementations§

Source§

impl Htl

Source

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

Source

pub fn install_test_lib(&self) -> Result<()>

Make require("htl.test") work at runtime and its types visible to the checker.

Source§

impl Htl

Source

pub fn new() -> Result<Self>

New state. Uses Lua::unsafe_new so stripped bytecode bundles can be loaded.

Source

pub fn from_lua(lua: Lua) -> Result<Self>

Attach the Teal compiler to an existing Lua state (the host’s own Lua).

Source

pub fn lua(&self) -> &Lua

Source

pub fn check(&self, file: &Path) -> Result<CheckInfo>

Type-check one file.

Source

pub fn gen_lua(&self, file: &Path) -> Result<(Option<String>, CheckInfo)>

Type-check and generate Lua source. None code means errors (see CheckInfo).

Source

pub fn configure_lints(&self, spec: &str) -> Result<()>

Configure lint rules: "+no-any,-shadow-local" on top of the defaults.

Source

pub fn lint_rules(&self) -> Result<Vec<String>>

Names of all lint rules (enabled or not).

Source

pub fn format_file(&self, file: &Path, indent: usize) -> Result<String>

Format a .tl file (whitespace-only formatter). Returns the formatted text.

Source

pub fn add_path(&self, dir: &Path) -> Result<()>

Prepend dir/?.tl;dir/?/init.tl to package.path (Teal resolves requires through it).

Source

pub fn install_searcher(&self) -> Result<()>

Install the strict .tl searcher: require of a .tl with type errors fails.

Source

pub fn preload(&self, name: &str, lua_src: &str) -> Result<()>

Register generated Lua source under a module name (package.preload).

Source

pub fn preload_bytes(&self, name: &str, bytecode: &[u8]) -> Result<()>

Register stripped bytecode (e.g. from include_tl_bytes!) under a module name.

Source

pub fn exec_bytes( &self, bytecode: &[u8], chunk_name: &str, args: &[String], ) -> Result<()>

Execute stripped bytecode with ... = args.

Source

pub fn preload_value(&self, name: &str, value: impl IntoLua) -> Result<()>

Register a ready-made value (typically a Rust-built table) as a module.

Source

pub fn set_arg(&self, script: &str, args: &[String]) -> Result<()>

Set the global arg table like the lua CLI does.

Source

pub fn exec( &self, lua_src: &str, chunk_name: &str, args: &[String], ) -> Result<()>

Execute Lua source with ... = args.

Source

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.

Source

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).

Source

pub fn install_bundle(&self, b: &Bundle) -> Result<()>

Install a searcher serving modules from a bundle.

Source

pub fn run_bundle(&self, b: &Bundle, args: &[String]) -> Result<()>

Install the bundle and run its entry module with ... = args.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.