Crate rlua

source · []
Expand description

High-level bindings to Lua

The rlua crate provides safe high-level bindings to the Lua programming language.

The Lua object

The main type exported by this library is the Lua struct. In addition to methods for executing Lua chunks or evaluating Lua expressions, it provides methods for creating Lua values and accessing the table of globals.

Converting data

The ToLua and FromLua traits allow conversion from Rust types to Lua values and vice versa. They are implemented for many data structures found in Rust’s standard library.

For more general conversions, the ToLuaMulti and FromLuaMulti traits allow converting between Rust types and any number of Lua values.

Most code in rlua is generic over implementors of those traits, so in most places the normal Rust data structures are accepted without having to write any boilerplate.

Custom Userdata

The UserData trait can be implemented by user-defined types to make them available to Lua. Methods and operators to be used from Lua can be added using the UserDataMethods API.


pub use crate::value::Nil;


Re-exports most types with an extra Lua* prefix to prevent name clashes.


Handle to an internal Lua userdata for any type that implements UserData.

Returned from Context::load and is used to finalize loading and executing Lua main chunks.

Contains information about currently executing Lua code.

Handle to an internal Lua function.

Determines when a hook function will be called by Lua.

Flags describing the set of lua modules to load.

A “light” userdata value. Equivalent to an unmanaged raw pointer.

Top level Lua struct which holds the Lua state itself.

Multiple Lua values used for both argument passing and also for multiple return values.

An auto generated key into the Lua registry.

Constructed by the Context::scope method, allows temporarily creating Lua userdata and callbacks that are not required to be Send or ’static.

Flags describing the set of lua modules to load.

Handle to an internal Lua string.

Handle to an internal Lua table.

An iterator over the pairs of a Lua table.

An iterator over the sequence part of a Lua table.

Handle to an internal Lua thread (or coroutine).

Wraps a variable number of Ts.


Error type returned by rlua methods.

Kinds of metamethods that can be overridden.

Status of a Lua thread (or coroutine).

A dynamically typed Lua value. The String, Table, Function, Thread, and UserData variants contain handle types into the internal Lua state. It is a logic error to mix handle types between separate Lua instances, or between a parent Lua instance and one received as a parameter in a Rust callback, and doing so will result in a panic.


Trait for types convertible from Value.

Trait for types that can be created from an arbitrary number of Lua values.

Trait for types convertible to Value.

Trait for types convertible to any number of Lua values.

Trait for custom userdata types.

Method registry for UserData implementors.

Type Definitions

Type of Lua integer numbers.

Type of Lua floating point numbers.

A specialized Result type used by rlua’s API.