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§
- AnyUser
Data - A handle to an arbitrary Lua userdata value.
- AppData
Ref - An immutable borrow of an application-data value of type
T. Mirrorsmlua::AppDataRef. - AppData
RefMut - A mutable borrow of an application-data value of type
T. Mirrorsmlua::AppDataRefMut. - Async
Thread - The
async-feature coroutine-as-Future/Streamdriver, re-exported when the umbrella’sasyncfeature (which forwards toluaur-rt/async) is on. TheAsyncThreaddriver — a coroutine being run to completion as a RustFuture/Stream(theasyncfeature). 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 ofmlua::debug::Debug. - Deserialize
Options - The
serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’sserdefeature (forwarding toluaur-rt/serde) is on. Options controllingDeserializerbehavior. Mirrorsmlua::serde::de::Options. - Function
- A handle to a callable Lua value (a Lua closure or a Rust function).
- Function
Info - Debug information about a
Function. Mirrorsmlua::debug::FunctionInfo(the subset Luau reports). - Light
User Data - 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’sserdefeature (forwarding toluaur-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’sserdefeature (forwarding toluaur-rt/serde) is on. A struct for serializing Rust values into Lua values. - LuaString
- A garbage-collected Lua string.
- Multi
Value - An ordered, growable sequence of Lua values, used to represent the multiple arguments / multiple return values that Lua functions can take and produce.
- Registry
Key - An owned reference to a value stored in the Lua registry.
- Scope
- A scope for creating lifetime-bounded Lua callbacks and userdata.
- Serializable
Table - The
serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’sserdefeature (forwarding toluaur-rt/serde) is on. A wrappedTablewith customized serialization behavior. Mirrors mlua’sSerializableTable. - Serializable
Value - The
serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’sserdefeature (forwarding toluaur-rt/serde) is on. A wrappedValuewith customized serialization behavior. Mirrorsmlua::SerializableValue. - Serialize
Options - The
serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’sserdefeature (forwarding toluaur-rt/serde) is on. Options controllingSerializerbehavior. Mirrorsmlua::serde::ser::Options. - StdLib
- A bit-set selecting which standard libraries to open. Mirrors
mlua::StdLib. - Table
- A handle to a Lua table.
- Table
Pairs - Iterator over a table’s key/value pairs (see
Table::pairs). - Table
Sequence - Iterator over a table’s sequence part (see
Table::sequence_values). - Thread
- A handle to a Lua thread (coroutine). Mirrors
mlua::Thread. - Type
Diagnostic - Static type-checking surface (the
typecheckfeature): the structuredTypeDiagnostictype plus the freecheck/check_with_definitionshelpers. TheLua/Chunkobjects gaincheck/add_definitionsmethods (seeLua::check/Chunk::check) that returnError::TypeError. One type-checker diagnostic with its source location (all 1-based). - User
Data Ref - A RAII guard for an immutable userdata borrow (
AnyUserData::borrow). Mirrorsmlua::UserDataRef. - User
Data RefMut - A RAII guard for a mutable userdata borrow (
AnyUserData::borrow_mut). Mirrorsmlua::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
Luainstance. Mirrorsmlua::WeakLua.
Enums§
- Chunk
Mode - How a chunk’s bytes are interpreted. Mirrors
mlua::ChunkMode. luaur-rt always loads text source, so this exists for signature parity withChunk::set_mode. - Debug
What - 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.
- Meta
Method - Kinds of metamethods that can be overridden on userdata.
- Thread
Status - 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§
- External
Error - Convenience for turning an arbitrary error/displayable into an
Error. - External
Result Resultextension mirroringmlua::ExternalResult: lift anyResult<T, E>into aluaurResultby converting the error.- FromLua
- Convert a single Lua
Valueinto a Rust value. - From
LuaMulti - Convert a sequence of Lua values into a Rust value.
- IntoLua
- Convert a Rust value into a single Lua
Value. - Into
LuaMulti - Convert a Rust value into a sequence of Lua values (multiple returns / args).
- LuaNative
Fn - A function/closure callable with a tuple of
FromLuaMultiarguments, abstracting over arity. Mirrorsmlua::LuaNativeFn. LetsFunction::wrapaccept||,|a|,|a, b|, … closures uniformly (the closure receives the converted args directly, not theLua). - LuaSerde
Ext - The
serde-feature Rust↔Lua serialization surface, re-exported when the umbrella’sserdefeature (forwarding toluaur-rt/serde) is on. Trait for serializing/deserializing Lua values using Serde. Mirrorsmlua::LuaSerdeExt. - Maybe
Send - See the
send-gated variant above. - Maybe
Sync - See the
send-gated variant above. - Type
Metatable - Luau built-in types that have a shared, per-type metatable settable via
Lua::set_type_metatable. Mirrors mlua’s sealedLuauTypetrait. - User
Data - A Rust type that can be exposed to Lua as userdata.
- User
Data Fields - Registrar passed to
UserData::add_fields. - User
Data Methods - Registrar passed to
UserData::add_methods.
Functions§
- check
- Static type-checking surface (the
typecheckfeature): the structuredTypeDiagnostictype plus the freecheck/check_with_definitionshelpers. TheLua/Chunkobjects gaincheck/add_definitionsmethods (seeLua::check/Chunk::check) that returnError::TypeError. Type-check Luausource. ReturnsOk(())if it type-checks clean, orErrof the structured diagnostics on type errors. - check_
modules - Static type-checking surface (the
typecheckfeature): the structuredTypeDiagnostictype plus the freecheck/check_with_definitionshelpers. TheLua/Chunkobjects gaincheck/add_definitionsmethods (seeLua::check/Chunk::check) that returnError::TypeError. Type-check a graph of Luau modules. - check_
modules_ with_ definitions - Static type-checking surface (the
typecheckfeature): the structuredTypeDiagnostictype plus the freecheck/check_with_definitionshelpers. TheLua/Chunkobjects gaincheck/add_definitionsmethods (seeLua::check/Chunk::check) that returnError::TypeError. Type-check a graph of Luau modules with extra host typedefinitionsin scope. Seecheck_modulesandcheck_with_definitions. - check_
with_ definitions - Static type-checking surface (the
typecheckfeature): the structuredTypeDiagnostictype plus the freecheck/check_with_definitionshelpers. TheLua/Chunkobjects gaincheck/add_definitionsmethods (seeLua::check/Chunk::check) that returnError::TypeError. Type-check Luausourcewith extra host typedefinitionsin scope. - compile
- Compile Luau
sourceto bytecode using default compile/parse options. - eval
- Compile, load and run
sourceon a fresh Luau VM, mirroring the referenceluauCLI (luau_rundriver): a fresh state with the standard library open, the chunk loaded into a new thread, andlua_resumeto 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’smacrosfeature), re-exported so users can write#[derive(luaur_rt::UserData)]/#[derive(luaur_rt::FromLua)]. Derive macro implementingFromLuafor aClonetype, recovering the value out of a Lua userdata of that type. - User
Data - The
#[derive(UserData)]/#[derive(FromLua)]procedural derive macros (mirroring mlua’smacrosfeature), re-exported so users can write#[derive(luaur_rt::UserData)]/#[derive(luaur_rt::FromLua)]. Derive macro implementingUserDatafor a struct, exposing its named fields to Lua.