Giter Site home page Giter Site logo

Serde support about rustler HOT 6 CLOSED

rusterlium avatar rusterlium commented on April 27, 2024 1
Serde support

from rustler.

Comments (6)

hansihe avatar hansihe commented on April 27, 2024 4

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.

scrogson avatar scrogson commented on April 27, 2024 2

@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.

sunny-g avatar sunny-g commented on April 27, 2024 1

@cgregfreeman Wrote a library called serde_rustler that should help with this :)

from rustler.

cgregfreeman avatar cgregfreeman commented on April 27, 2024

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.

turion avatar turion commented on April 27, 2024

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.

evnu avatar evnu commented on April 27, 2024

Closing in favor of #200.

from rustler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.