Skip to main content

Crate luaur

Crate luaur 

Source
Expand description

§luaur

A faithful Rust translation of Luau — Roblox’s typed Lua. This umbrella crate re-exports the individual layers (lexer/parser/AST, bytecode, compiler, register VM, type checker, config and require resolution) and provides three thin convenience helpers — compile, eval, and check — for the common “compile a string / run a string / type-check a string” cases.

For finer-grained control depend on the sub-crates directly; they are all re-exported here as modules.

luaur::eval("assert(1 + 1 == 2)").unwrap();
let bytecode = luaur::compile("return 2 + 2").unwrap();
assert!(!bytecode.is_empty());
luaur::check("local x: number = 1").unwrap();

Re-exports§

pub use luaur_analysis as analysis;
pub use luaur_ast as ast;
pub use luaur_bytecode as bytecode;
pub use luaur_common as common;
pub use luaur_compiler as compiler;
pub use luaur_config as config;
pub use luaur_require as require;
pub use luaur_rt as rt;
pub use luaur_vm as vm;
pub use Nil;

Modules§

prelude
Common entry points, re-exported for convenience.

Structs§

AnyUserData
A handle to an arbitrary Lua userdata value.
AppDataRef
An immutable borrow of an application-data value of type T. Mirrors mlua::AppDataRef.
AppDataRefMut
A mutable borrow of an application-data value of type T. Mirrors mlua::AppDataRefMut.
AsyncThread
The async-feature coroutine-as-Future/Stream driver, re-exported when the umbrella’s async feature (which forwards to luaur-rt/async) is on. The AsyncThread driver — a coroutine being run to completion as a Rust Future/Stream (the async feature). A coroutine being driven to completion by a Rust executor.
Buffer
A Luau buffer type.
Chunk
A not-yet-executed piece of Lua source.
Compiler
Luau bytecode compiler options, mirroring mlua::Compiler.
Debug
A snapshot of one activation record, resolved from a stack level via lua_getinfo. Mirrors the informational subset of mlua::debug::Debug.
DeserializeOptions
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. Options controlling Deserializer behavior. Mirrors mlua::serde::de::Options.
Function
A handle to a callable Lua value (a Lua closure or a Rust function).
FunctionInfo
Debug information about a Function. Mirrors mlua::debug::FunctionInfo (the subset Luau reports).
LightUserData
A Lua light userdata: an opaque raw pointer value. Mirrors mlua::LightUserData.
Lua
A handle to a Lua interpreter.
LuaDeserializer
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. A struct for deserializing Lua values into Rust values.
LuaOptions
Per-VM behavioral options. Mirrors mlua::LuaOptions.
LuaSerializer
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. A struct for serializing Rust values into Lua values.
LuaString
A garbage-collected Lua string.
MultiValue
An ordered, growable sequence of Lua values, used to represent the multiple arguments / multiple return values that Lua functions can take and produce.
RegistryKey
An owned reference to a value stored in the Lua registry.
Scope
A scope for creating lifetime-bounded Lua callbacks and userdata.
SerializableTable
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. A wrapped Table with customized serialization behavior. Mirrors mlua’s SerializableTable.
SerializableValue
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. A wrapped Value with customized serialization behavior. Mirrors mlua::SerializableValue.
SerializeOptions
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. Options controlling Serializer behavior. Mirrors mlua::serde::ser::Options.
StdLib
A bit-set selecting which standard libraries to open. Mirrors mlua::StdLib.
Table
A handle to a Lua table.
TablePairs
Iterator over a table’s key/value pairs (see Table::pairs).
TableSequence
Iterator over a table’s sequence part (see Table::sequence_values).
Thread
A handle to a Lua thread (coroutine). Mirrors mlua::Thread.
TypeDiagnostic
Static type-checking surface (the typecheck feature): the structured TypeDiagnostic type plus the free check / check_with_definitions helpers. The Lua/Chunk objects gain check / add_definitions methods (see Lua::check / Chunk::check) that return Error::TypeError. One type-checker diagnostic with its source location (all 1-based).
UserDataRef
A RAII guard for an immutable userdata borrow (AnyUserData::borrow). Mirrors mlua::UserDataRef.
UserDataRefMut
A RAII guard for a mutable userdata borrow (AnyUserData::borrow_mut). Mirrors mlua::UserDataRefMut.
Variadic
A wrapper collecting “the rest of” a Lua argument list (or producing a variable number of return values).
Vector
A Luau vector type.
WeakLua
A weak handle to a Lua instance. Mirrors mlua::WeakLua.

Enums§

ChunkMode
How a chunk’s bytes are interpreted. Mirrors mlua::ChunkMode. luaur-rt always loads text source, so this exists for signature parity with Chunk::set_mode.
DebugWhat
What kind of function an activation record refers to. Mirrors the relevant part of mlua::debug::DebugSource::what.
Error
Errors that can occur when interacting with the Lua engine.
MetaMethod
Kinds of metamethods that can be overridden on userdata.
ThreadStatus
Status of a Lua thread (coroutine). Mirrors mlua::ThreadStatus.
Value
A dynamically typed Lua value.
VmState
The action an interrupt callback asks the VM to take. Mirrors mlua::VmState.

Traits§

ExternalError
Convenience for turning an arbitrary error/displayable into an Error.
ExternalResult
Result extension mirroring mlua::ExternalResult: lift any Result<T, E> into a luaur Result by converting the error.
FromLua
Convert a single Lua Value into a Rust value.
FromLuaMulti
Convert a sequence of Lua values into a Rust value.
IntoLua
Convert a Rust value into a single Lua Value.
IntoLuaMulti
Convert a Rust value into a sequence of Lua values (multiple returns / args).
LuaNativeFn
A function/closure callable with a tuple of FromLuaMulti arguments, abstracting over arity. Mirrors mlua::LuaNativeFn. Lets Function::wrap accept ||, |a|, |a, b|, … closures uniformly (the closure receives the converted args directly, not the Lua).
LuaSerdeExt
The serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’s serde feature (forwarding to luaur-rt/serde) is on. Trait for serializing/deserializing Lua values using Serde. Mirrors mlua::LuaSerdeExt.
MaybeSend
See the send-gated variant above.
MaybeSync
See the send-gated variant above.
TypeMetatable
Luau built-in types that have a shared, per-type metatable settable via Lua::set_type_metatable. Mirrors mlua’s sealed LuauType trait.
UserData
A Rust type that can be exposed to Lua as userdata.
UserDataFields
Registrar passed to UserData::add_fields.
UserDataMethods
Registrar passed to UserData::add_methods.

Functions§

check
Static type-checking surface (the typecheck feature): the structured TypeDiagnostic type plus the free check / check_with_definitions helpers. The Lua/Chunk objects gain check / add_definitions methods (see Lua::check / Chunk::check) that return Error::TypeError. Type-check Luau source. Returns Ok(()) if it type-checks clean, or Err of the structured diagnostics on type errors.
check_modules
Static type-checking surface (the typecheck feature): the structured TypeDiagnostic type plus the free check / check_with_definitions helpers. The Lua/Chunk objects gain check / add_definitions methods (see Lua::check / Chunk::check) that return Error::TypeError. Type-check a graph of Luau modules.
check_modules_with_definitions
Static type-checking surface (the typecheck feature): the structured TypeDiagnostic type plus the free check / check_with_definitions helpers. The Lua/Chunk objects gain check / add_definitions methods (see Lua::check / Chunk::check) that return Error::TypeError. Type-check a graph of Luau modules with extra host type definitions in scope. See check_modules and check_with_definitions.
check_with_definitions
Static type-checking surface (the typecheck feature): the structured TypeDiagnostic type plus the free check / check_with_definitions helpers. The Lua/Chunk objects gain check / add_definitions methods (see Lua::check / Chunk::check) that return Error::TypeError. Type-check Luau source with extra host type definitions in scope.
compile
Compile Luau source to bytecode using default compile/parse options.
eval
Compile, load and run source on a fresh Luau VM, mirroring the reference luau CLI (luau_run driver): a fresh state with the standard library open, the chunk loaded into a new thread, and lua_resume to execute it.

Type Aliases§

Integer
The integer type exposed by the API. Mirrors mlua::Integer (i64).
Number
The float type exposed by the API. Mirrors mlua::Number (f64).
Result
The result type used throughout luaur-rt, mirroring [mlua::Result].

Derive Macros§

FromLua
The #[derive(UserData)] / #[derive(FromLua)] procedural derive macros (mirroring mlua’s macros feature), re-exported so users can write #[derive(luaur_rt::UserData)] / #[derive(luaur_rt::FromLua)]. Derive macro implementing FromLua for a Clone type, recovering the value out of a Lua userdata of that type.
UserData
The #[derive(UserData)] / #[derive(FromLua)] procedural derive macros (mirroring mlua’s macros feature), re-exported so users can write #[derive(luaur_rt::UserData)] / #[derive(luaur_rt::FromLua)]. Derive macro implementing UserData for a struct, exposing its named fields to Lua.