Crate rlua_serde[−][src]
This crate allows you to serialize and deserialize any type that implements
serde::Serialize
and serde::Deserialzie
into/from rlua::Value
.
Implementation is similar to serde_json::Value
Example usage:
extern crate serde; #[macro_use] extern crate serde_derive; extern crate rlua; extern crate rlua_serde; fn main() { #[derive(Serialize, Deserialize)] struct Foo { bar: u32, baz: Vec<String>, } let lua = rlua::Lua::new(); let foo = Foo { bar: 42, baz: vec![String::from("fizz"), String::from("buzz")], }; let value = rlua_serde::to_value(&lua, &foo).unwrap(); lua.globals().set("value", value).unwrap(); lua.exec::<_, ()>( r#" assert(value["bar"] == 42) assert(value["baz"][2] == "buzz") "#, None, ).unwrap() }
Modules
de | |
error | |
ser |
Functions
from_value | |
to_value |