Comments (11)
Any news on this?
from capnproto-rust.
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.
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.
Good point about the schema, I initially thought that capnpc-rust could generate the needed struct
s 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.
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.
Thanks for feedback, closing this issue...
from capnproto-rust.
Today I came across serde-protobuf. I'm not sure exactly what it does, but it seems relevant to this discussion.
from capnproto-rust.
Do you have a plan to support JSON encoding and decoding in capnproto-rust?
from capnproto-rust.
@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.
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.
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)
- Primitive list panicks if the list type is `Void` HOT 1
- Null values for non active union members HOT 3
- Switch Allocator to act more like an owned arena HOT 8
- Reader fails with out of bounds pointer error when reading from compressed stream HOT 1
- Revert text setter ergonomics pessification; add raw_set methods HOT 6
- calculator example fails with java server: Cannot read capability pointer without capTable HOT 2
- c++.capnp compiles to unusable module name HOT 6
- How to send generated readers across threads HOT 3
- From bytes to TypedReader HOT 6
- Allowing construction of NoAllocSliceSegments with buffer and NoAllocBufferSegmentType HOT 7
- Kudos to builders of this Rust library - Every single one of you. HOT 3
- [Question]How to extract generic type values HOT 5
- capnp_rpc does not work on monoio HOT 4
- Dynamic parsing of fields may panic HOT 1
- traits.ListIter incorrectly implementing ExactSizeIterator HOT 1
- oc
- Using same schema file for both Rust and C++ HOT 1
- doc: read_message_from_flat_slice_no_alloc docstring bad autocomplete HOT 1
- Making rust capn proto fully async HOT 2
- Is there any reason why Rc<RefCell> is used compared to Arc<Mutex>?
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 capnproto-rust.