fix build

This commit is contained in:
Cadey Ratio 2020-07-05 20:50:33 -04:00
parent bcb3083252
commit 9d12a4fc4b
7 changed files with 32 additions and 23 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
eval "$(lorri direnv)"

View File

@ -1,15 +1,15 @@
[package]
name = "rlua_serde"
name = "mlua_serde"
version = "0.4.0"
authors = ["zrkn <zrkn@email.su>"]
description = "Serde (De)serializer implementation for rlua Value"
repository = "https://github.com/zrkn/rlua_serde/"
description = "Serde (De)serializer implementation for mlua Value"
repository = "https://tulpa.dev/lua/mlua_serde/"
readme = "README.md"
keywords = ["lua", "serde"]
license = "MIT"
[dependencies]
rlua = "0.17"
mlua = { version = "0.4", features = ["lua53"] }
serde = "1.0"
[dev-dependencies]

8
shell.nix Normal file
View File

@ -0,0 +1,8 @@
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
buildInputs = with pkgs; [
rustc cargo rls lua5_3 pkg-config
];
}

View File

@ -1,7 +1,7 @@
use serde;
use serde::de::IntoDeserializer;
use rlua::{Value, TablePairs, TableSequence};
use mlua::{Value, TablePairs, TableSequence};
use error::{Error, Result};
@ -267,7 +267,7 @@ impl<'lua, 'de> serde::de::VariantAccess<'de> for VariantDeserializer<'lua> {
#[cfg(test)]
mod tests {
use rlua::Lua;
use mlua::Lua;
use from_value;

View File

@ -3,7 +3,7 @@ use std::error::Error as StdError;
use std::result::Result as StdResult;
use serde;
use rlua::Error as LuaError;
use mlua::Error as LuaError;
#[derive(Debug)]

View File

@ -1,5 +1,5 @@
//! This crate allows you to serialize and deserialize any type that implements
//! `serde::Serialize` and `serde::Deserialize` into/from `rlua::Value`.
//! `serde::Serialize` and `serde::Deserialize` into/from `mlua::Value`.
//!
//! Implementation is similar to `serde_json::Value`
//!
@ -9,8 +9,8 @@
//! extern crate serde;
//! #[macro_use]
//! extern crate serde_derive;
//! extern crate rlua;
//! extern crate rlua_serde;
//! extern crate mlua;
//! extern crate mlua_serde;
//!
//! fn main() {
//! #[derive(Serialize, Deserialize)]
@ -19,14 +19,14 @@
//! baz: Vec<String>,
//! }
//!
//! let lua = rlua::Lua::new();
//! let lua = mlua::Lua::new();
//! lua.context(|lua| {
//! let foo = Foo {
//! bar: 42,
//! baz: vec![String::from("fizz"), String::from("buzz")],
//! };
//!
//! let value = rlua_serde::to_value(lua, &foo).unwrap();
//! let value = mlua_serde::to_value(lua, &foo).unwrap();
//! lua.globals().set("value", value).unwrap();
//! lua.load(
//! r#"
@ -37,7 +37,7 @@
//! }
//! ```
extern crate rlua;
extern crate mlua;
#[macro_use]
extern crate serde;
#[cfg(test)]
@ -49,11 +49,11 @@ pub mod ser;
pub mod de;
use rlua::{Context, Value, Error};
use mlua::{Lua, Value, Error};
pub fn to_value<T: serde::Serialize>(lua: Context, t: T) -> Result<Value, Error> {
let serializer = ser::Serializer { lua };
pub fn to_value<'lua, T: serde::Serialize>(lua: &'lua Lua, t: T) -> Result<Value<'lua>, Error> {
let serializer = ser::Serializer { lua: &lua };
Ok(t.serialize(serializer)?)
}

View File

@ -1,13 +1,13 @@
use serde;
use rlua::{Context, Value, Table, String as LuaString};
use mlua::{Lua, Value, Table, String as LuaString};
use to_value;
use error::{Error, Result};
pub struct Serializer<'lua> {
pub lua: Context<'lua>,
pub lua: &'lua Lua,
}
impl<'lua> serde::Serializer for Serializer<'lua> {
@ -208,7 +208,7 @@ impl<'lua> serde::Serializer for Serializer<'lua> {
pub struct SerializeVec<'lua> {
lua: Context<'lua>,
lua: &'lua Lua,
table: Table<'lua>,
idx: u64,
}
@ -262,7 +262,7 @@ impl<'lua> serde::ser::SerializeTupleStruct for SerializeVec<'lua> {
pub struct SerializeTupleVariant<'lua> {
lua: Context<'lua>,
lua: &'lua Lua,
name: LuaString<'lua>,
table: Table<'lua>,
idx: u64,
@ -289,7 +289,7 @@ impl<'lua> serde::ser::SerializeTupleVariant for SerializeTupleVariant<'lua> {
pub struct SerializeMap<'lua> {
lua: Context<'lua>,
lua: &'lua Lua,
table: Table<'lua>,
next_key: Option<Value<'lua>>
}
@ -339,7 +339,7 @@ impl<'lua> serde::ser::SerializeStruct for SerializeMap<'lua> {
pub struct SerializeStructVariant<'lua> {
lua: Context<'lua>,
lua: &'lua Lua,
name: LuaString<'lua>,
table: Table<'lua>,
}
@ -365,7 +365,7 @@ impl<'lua> serde::ser::SerializeStructVariant for SerializeStructVariant<'lua> {
#[cfg(test)]
mod tests {
use rlua::Lua;
use mlua::Lua;
use super::*;
#[test]