mlua-rs/mlua

Public

High level Lua 5.5/5.4/5.3/5.2/5.1 (including LuaJIT) and Luau bindings to Rust with async/await support

  • Stars2.9k+6 tuần này
  • Forks216
  • Watchers20
  • Issues49
  • Ngày tạo30/11/2019
  • Cập nhật gần nhất03/10/2026
  • Ngôn ngữRust
  • Giấy phép—
README.md29.5 KBRaw

mlua

Build Status Latest Version API Documentation Coverage Status MSRV

Guided Tour | Benchmarks | FAQ

mlua is a set of bindings to the Lua programming language for Rust with a goal of providing a safe (as much as possible), high level, easy to use, practical and flexible API.

Started as an rlua fork, mlua supports Lua 5.5, 5.4, 5.3, 5.2, 5.1 (including LuaJIT) and Luau and allows writing native Lua modules in Rust as well as using Lua in a standalone mode.

mlua is tested on Windows/macOS/Linux including module mode in GitHub Actions on x86_64 platforms and cross-compilation to aarch64 (other targets are also supported).

WebAssembly (WASM) is supported through the wasm32-unknown-emscripten target for all Lua/Luau versions excluding JIT.

Usage

Feature flags

mlua uses feature flags to reduce the number of dependencies and compiled code, and allow choosing only the required set of features. Below is a list of the available feature flags. By default mlua does not enable any features.

  • lua55: enable Lua 5.5 support
  • lua54: enable Lua 5.4 support
  • lua53: enable Lua 5.3 support
  • lua52: enable Lua 5.2 support
  • lua51: enable Lua 5.1 support
  • luajit: enable LuaJIT support
  • luajit52: enable LuaJIT support with partial compatibility with Lua 5.2
  • luau: enable Luau support (auto vendored mode)
  • luau-jit: enable Luau support with JIT backend.
  • luau-vector4: enable Luau support with 4-dimensional vector.
  • vendored: build static Lua(JIT) libraries from sources during mlua compilation using lua-src or luajit-src
  • module: enable module mode (building loadable cdylib library for Lua)
  • async: enable async/await support (any executor can be used, eg. tokio or async-std)
  • send: make mlua::Lua: Send + Sync (adds Send requirement to mlua::Function and Send + Sync to mlua::UserData)
  • error-send: make mlua::Error: Send + Sync
  • serde: add serialization and deserialization support to mlua types using serde
  • macros: enable procedural macros (such as chunk!)
  • anyhow: enable anyhow::Error conversion into Lua
  • userdata-wrappers: opt into impl UserData for Rc<T>/Arc<T>/Rc<RefCell<T>>

Nội dung README thuộc về mlua-rs và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/mlua-rs/mlua