Giter VIP home page Giter VIP logo

Comments (11)

kaligrafy avatar kaligrafy commented on September 22, 2024 15

Any news on this?

from capnproto-rust.

dwrensha avatar dwrensha commented on September 22, 2024 2

Hi!

My impression is that Cap'n Proto would not be a very good fit for Serde integration, mainly because Cap'n Proto wants to define data types in schemas external to Rust code. I have an old post on this topic. (The libserialize discussed there is now called rustc_serialize, if I remember correctly.)

Do you have a specific use case in mind?

from capnproto-rust.

burdges avatar burdges commented on September 22, 2024

I'd think cap'n proto could generate the serde attributes from its schema, maybe useful if someone must work around company policies like always use json or xml for such and such.

from capnproto-rust.

erasmospunk avatar erasmospunk commented on September 22, 2024

Good point about the schema, I initially thought that capnpc-rust could generate the needed structs with Serde's annotations & any runtime code. Not sure if this is simple, especially considering that Serde does not support protocol buffers.

My use case is converting from JSON to Capnproto as an internal representation for microservices. Using the Serde lib could potentially make the transcoding with less code.

If you think that this is something that does not make sense for this project, feel free to close this issue.

from capnproto-rust.

dwrensha avatar dwrensha commented on September 22, 2024

I do think think that it would be good to have JSON <--> Cap'n Proto support in capnproto-rust, but I'm not sure that it would make sense to involve Serde. I would probably start by looking at how capnproto-c++ supports JSON encoding and decoding.

from capnproto-rust.

erasmospunk avatar erasmospunk commented on September 22, 2024

Thanks for feedback, closing this issue...

from capnproto-rust.

dwrensha avatar dwrensha commented on September 22, 2024

Today I came across serde-protobuf. I'm not sure exactly what it does, but it seems relevant to this discussion.

from capnproto-rust.

piaoger avatar piaoger commented on September 22, 2024

Do you have a plan to support JSON encoding and decoding in capnproto-rust?

from capnproto-rust.

dwrensha avatar dwrensha commented on September 22, 2024

@piaoger It would be good to have, but I don't have any immediate plans to work on it.

I think the way forward would be to implement dynamic reflection as in the C++ reference implementation, so that to_json() and from_json() functions could work for any type of message without needing any extra generated code.

from capnproto-rust.

sffc avatar sffc commented on September 22, 2024

Cap'n Proto works with aligned data, so it has the capability to return things like &[u32] on little-endian systems, which can be crucial for performance.

Serde on the other hand is capable of zero-copy deserializing &[u8] (and &str) but not anything wider than that. You would therefore be losing out on certain performance characteristics and zero-copy deserialization by trying to fit Cap'n Proto into Serde's data model.

It is possible to model slices of complex types on top of byte buffers by using unaligned reads, which incurs a small performance penalty, but in practice this penalty is often in the noise. The zerovec crate provides these abstractions so that you can use zero-copy deserialization of complex types with Serde. (Disclaimer: I am a maintainer of the zerovec crate.)

from capnproto-rust.

burdges avatar burdges commented on September 22, 2024

As an aside, we discussed multi- architecture layout ideas in https://internals.rust-lang.org/t/multi-architecture-layout/18538 which likely never happens in rustc, but maybe gives someone ideas.

from capnproto-rust.

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.