A high-level Rust binding for Lua 5.2, enabling safe interaction with Lua variables, functions, and tables.
hlua is a Rust library that provides a high-level binding for Lua 5.2, allowing Rust applications to safely interface with the Lua scripting language. It enables executing Lua code, reading/writing variables, exposing Rust functions, and manipulating Lua tables without direct stack access. The library solves the problem of embedding Lua in Rust with type safety and ergonomic APIs.
Rust developers who need to embed Lua scripting in their applications, such as game developers, tool creators, or those building extensible systems. It's ideal for those who want safe, high-level interaction with Lua without dealing with low-level C APIs.
Developers choose hlua over lower-level bindings because it offers a safe, idiomatic Rust API that prevents common errors like stack misuse, provides seamless type conversions, and includes features like container support and user data. Its focus on safety without sacrificing functionality makes it a robust choice for embedding Lua.
Rust library to interface with Lua
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Ensures safe variable access by enforcing Rust types like i32 and bool when reading/writing Lua globals, preventing type mismatches at compile time.
Abstracts the Lua stack with simple methods like set and get, making it easy to execute Lua code and manipulate tables without low-level details.
Allows wrapping Rust functions and closures for Lua calls with compile-time lifetime checks, ensuring memory safety.
Supports reading and writing Rust containers like Vec and HashMap to/from Lua tables, simplifying data exchange between the languages.
Only supports Lua 5.2, lacking features from newer versions like integer division in Lua 5.3, which may hinder adoption in modern projects.
The user data API is marked as 'very unstable' in the README, leading to potential breaking changes and increased maintenance burden for custom types.
Cannot read all Lua tables into Rust Vecs; for example, sparse arrays or non-numeric keys result in None, restricting data handling flexibility.
High-level abstractions may add overhead compared to direct C bindings, which could be a concern in performance-sensitive applications.