convert_data

Function convert_data 

Source
pub fn convert_data(value: impl Serialize) -> Result<String, DarkluaError>
Expand description

Convert serializable data into a Lua module.

This function takes any value that implements Serialize and converts it into a Lua module that returns the serialized data. The resulting Lua code will be a module that returns a table containing the serialized data.

ยงExample

#[derive(Serialize)]
struct ExampleData {
    name: String,
    value: i32,
}

let config = ExampleData {
    name: "test".to_string(),
    value: 42,
};

let lua_code = convert_data(config).unwrap();

assert_eq!(lua_code, "return{name='test',value=42}");