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] [package]
name = "rlua_serde" name = "mlua_serde"
version = "0.4.0" version = "0.4.0"
authors = ["zrkn <zrkn@email.su>"] authors = ["zrkn <zrkn@email.su>"]
description = "Serde (De)serializer implementation for rlua Value" description = "Serde (De)serializer implementation for mlua Value"
repository = "https://github.com/zrkn/rlua_serde/" repository = "https://tulpa.dev/lua/mlua_serde/"
readme = "README.md" readme = "README.md"
keywords = ["lua", "serde"] keywords = ["lua", "serde"]
license = "MIT" license = "MIT"
[dependencies] [dependencies]
rlua = "0.17" mlua = { version = "0.4", features = ["lua53"] }
serde = "1.0" serde = "1.0"
[dev-dependencies] [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;
use serde::de::IntoDeserializer; use serde::de::IntoDeserializer;
use rlua::{Value, TablePairs, TableSequence}; use mlua::{Value, TablePairs, TableSequence};
use error::{Error, Result}; use error::{Error, Result};
@ -267,7 +267,7 @@ impl<'lua, 'de> serde::de::VariantAccess<'de> for VariantDeserializer<'lua> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use rlua::Lua; use mlua::Lua;
use from_value; use from_value;

View File

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

View File

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

View File

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