Crate mlua_serde[][src]

This crate allows you to serialize and deserialize any type that implements serde::Serialize and serde::Deserialize into/from mlua::Value.

Implementation is similar to serde_json::Value

Example usage:

extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate mlua;
extern crate mlua_serde;

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

    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();
    lua.load(
        r#"
            assert(value["bar"] == 42)
            assert(value["baz"][2] == "buzz")
        "#).exec().unwrap();
}

Modules

de
error
ser

Functions

from_value
to_value