Comments (4)
Agreed. Implemented in separate crate - https://github.com/zrkn/rlua_serde/
Thanks for feedback, I think we can close this.
from rlua.
I've definitely had the same idea, it's cool that you implemented this and I'll definitely take a look at it.
The problem with doing this though, is that it creates two paths for serialization, the Serialize / Deserialize path and the ToLua / FromLua path.
If there a way that we could provide some sort of to_lua_serialize!
and from_lua_deserialize
macros that make a struct that is Serialize / Deserialize implement ToLua / FromLua, that would be really interesting. I haven't looked into it, but I don't think that's possible to do in a way where it forwards to ToLua / FromLua on the fields of the struct implementing Serialize / Deserialize, and if you have two separate serialization systems, I don't think that's going to work out very well.
The problem is something like this, suppose you have a struct Complicated
with a bespoke impl ToLua for Complicated
and impl FromLua for Complicated
. Then, if you have a #[derive(Serialize, Deserialize)] struct Compound { complicated: Complicated }
, at best using Serialize / Deserialize to do the Lua conversion won't compile, but at worst it may actually use a serialization that you don't actually want. I don't really want there to be multiple parallel ways to do Lua serialization.
I might be wrong though, and that might be feasible to forward to ToLua / FromLua using the Serialize / Deserialize traits, and if so that might be a viable strategy to try?
from rlua.
There is a difference between ToLua
/FromLua
conversion path and Serialize
/Deserialize
, which can be a reason to keep them separate. ToLua
/FromLua
consumes self
, when Serialize
/Deserialize
takes it by reference. Basically, first is conversion and second is serialization which are a bit different operations. End user can choose which is more appropriate for them.
from rlua.
Hmm, you're right, it's not really possible to combine them.
I'm not sure having that functionality in this crate is the right choice, would it be possible to have Serialize / Deserialize based Lua conversion as an external crate? Maybe you could have an extension trait on Lua that adds pack_serde
and unpack_serde
?
On a side note, I would eventually like to have some kind of ToLua / FromLua derive procedural macro.
from rlua.
Related Issues (20)
- Possible bug with __newindex not called on numeric indexing HOT 4
- Question: How to exec multiple things at once? HOT 4
- Segfault on clone of #[repr(C)] userdata subfield HOT 9
- ios build error HOT 7
- examples for error handling HOT 2
- Example for eval return a struct? HOT 1
- Cannot load DLLs in v0.19 HOT 6
- Missing mutable borrows for Table<'lua> HOT 2
- Context.create_sequence_from should support references HOT 1
- Undefined symbol lua_checkstack HOT 8
- Crash on empty source HOT 2
- custom runtime path HOT 3
- creating a `require`-able module HOT 8
- [Request] UserData::from_lua HOT 1
- Suggestion: proc_macro for LuaUserDataMethods::add_method HOT 3
- No documentation on how to use LuaRocks with rlua HOT 3
- Rlua + Luarocks Modules -> Fail to load HOT 3
- Memory leak when using system-luajit HOT 2
- Merge with mlua HOT 32
- [Typo] Example says laoded(instead of loaded) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rlua.