Comments (6)
While it is true that Serde wasn't what I thought of when I opened this issue, @cgregfreeman does have a valid point.
Serde has established a very well understood and common interface for serializing and deserializing data from a wide range of formats. While it is true that going through a binary format would be unnecessary overhead, it would be possible to implement a Serde serializer and deserializer for working directly with Erlang terms.
I recall looking at this earlier in the project as a potential alternative to having our custom interface for working with Erlang terms. The reason why I chose to go with our own interface was that it was not possible to work with lifetimes in the way we needed through Serde. This would force us to copy a lot more data than strictly necessary, and we would therefore impose a fairly large non-negotiable performance overhead on the user.
It would be very nice to have a Serde interface in addition to the current interface. While it would be less efficient for some tasks, it would make a lot of things much easier for the user.
from rustler.
@cgregfreeman using JSON back and forth is unnecessary overhead.
This is issue is geared towards being able to pass in maps or keyword lists (a list of 2-element tuples where the keys are atoms) and be able to extract out items from those data structures more easily.
from rustler.
@cgregfreeman Wrote a library called serde_rustler that should help with this :)
from rustler.
This would be fantastic.
I was able to get Serde to work very quickly with Rustler. However, this involves encoding/decoding JSON to pass it into the NIF. I suppose other formats like BSON or CBOR could be used, but they all add some overhead.
Serde looks to use a Derive macro for generating the boilerplate required so that any rust structs can have the serialize/deserialize methods automatically generated.
Would have such a macro in Rustler be the right tool for the job?
from rustler.
So is the idea to incorporate serde_rustler
into the rusterlium
codebase in the long run? Or depend on it for code generation?
from rustler.
Closing in favor of #200.
from rustler.
Related Issues (20)
- 1.65.0 Clippy complaining in `NifStruct` derives. HOT 2
- An optional crate feature to switch from Elixir `nil` to Erlang `undefined`? HOT 3
- Option to exclude or ignore specific artifacts HOT 2
- nif_panicked does not show the panic message HOT 2
- Elixir errors using Rust's `?` HOT 5
- NIF code trying to using MongoDB sync client hangs while trying to connect to DB HOT 2
- Check if Term is float HOT 5
- NifMap expansion error with rustler v0.27.0 HOT 2
- Update changelog for 0.27 HOT 1
- Store rustler template outside of priv/? HOT 2
- how to custom build target arch?
- can you support cargo-zigbuild? HOT 2
- `nif` macro fails with macro arguments HOT 2
- New Binary from Vec or Slice
- Support for enif_monitor_process HOT 1
- resource with lifetime
- Expose `enif_is_process_alive` HOT 4
- rustler errors on OTP26 HOT 1
- How to conveniently work with binaries as vectors of bytes?
- Why does Term::map_from_pairs return a NifResult?
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 rustler.