Serde support for mlua
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cadey Ratio 28ab03a516 update docs 3 weeks ago
src fully adapt to mlua 10 months ago
.envrc fix build 10 months ago
.gitignore Initial commit 3 years ago
Cargo.toml update to 0.6.0 3 weeks ago
LICENSE Add LICENSE file 3 years ago update docs 3 weeks ago
shell.nix update README for publishing 10 months ago


Implementation of serde Serializer/Deserializer for mlua::Value

License: MIT Documentation

More information about this crate can be found in the crate documentation.


To use mlua_serde, first add this to your Cargo.toml:

mlua_serde = { version = "0.6", features = ["lua53"] }

You must choose between Lua 5.1, 5.2, 5.3 and 5.4. To use Lua 5.4, change lua53 for lua54 like this:

mlua_serde = { version = "0.6", features = ["lua54"] }

If you don't have lua installed on your system for some reason, use the vendored feature:

mlua_serde = { version = "0.6", features = ["lua53", "vendored"] }

Next, you can use to_value/from_value functions to serialize/deserialize:

#[derive(Serialize, Deserialize)]
struct Foo {
    bar: u32,
    baz: Vec<String>,

fn main() {
    let lua = mlua::Lua::new();
    let foo = Foo {
        bar: 42,
        baz: vec![String::from("fizz"), String::from("buzz")],

    let value = mlua_serde::to_value(lua, &foo).unwrap();
    lua.globals().set("value", value).unwrap();
            assert(value["bar"] == 42)
            assert(value["baz"][2] == "buzz")