Comments (10)
You can get the bytes by calling message.get_segments_for_output()
, which will give you a single-segment OutputSegments
.
Currently there is no way to use the packed encoding in no-alloc mode. I think we could add support for that and for plain serialize_packed::write_message()
by putting the multi-segment support behind a #[cfg]
attribute.
from capnproto-rust.
Thanks for help.
Is adding support for packed encoding in no-alloc mode something I could help with?
from capnproto-rust.
The big obstacle I see is on the reading side of things. Currently serialize_packed::read_message()
allocates a vector on the heap:
capnproto-rust/capnp/src/serialize.rs
Line 239 in 18d362f
It's unclear to me how we should make that work in the no-alloc case. I suppose we need to add a way to make that allocation configurable, but I don't see an obvious nice way to do it.
from capnproto-rust.
Usually in the situations like that the user should decide of the size of the buffer used to serialize/deserialize data.
I used in the past this library for the c++/protobuf: https://embeddedproto.com/ and this is written in an elegant way. But using the same approach would require a lot of work here. And of course this library is only targeting embedded development.
from capnproto-rust.
We could add a serialize::read_message_into_buffer_segments()
function which is like serialize::read_message()
, but additionally takes a &mut [u8]
to use as the backing storage, and returns a message::Reader<BufferSegments<&[u8]>>
(instead of a message::Reader<OwnedSegments>
).
from capnproto-rust.
I can try to play a little bit with it in the upcoming days if you want, but be aware I am not very familiar with the code and CapN proto library 😄
Off topic question:
I'm testing the library a little bit and I added AnyPointer
and List(Uint16)
to one struct. But when I call init_
method to initialize the field the struct itself is borrowed so I cannot make another call to initialize another field. Is this a limitation? Of is there another way?
from capnproto-rust.
But when I call init_ method to initialize the field the struct itself is borrowed so I cannot make another call to initialize another field.
You cannot have a mutable reference to both child fields at the same time, but you can initialize them sequentially using the reborrow()
method: https://dwrensha.github.io/capnproto-rust/2014/12/27/custom-mutable-references.html
from capnproto-rust.
#451 adds no-alloc serialize_packed::write_message()
and serialize_packed::read_message_no_alloc()
.
from capnproto-rust.
Fixed in #451, and released in capnp-v0.18.5.
from capnproto-rust.
Wow, nicely done 🎉 I will test it for sure
from capnproto-rust.
Related Issues (20)
- Backport capnp-futures changes from master to 0.14 version HOT 2
- Invoking closure on the event loop to get a mutable reference to self HOT 1
- How to read unknown number of messages HOT 2
- Serializing message to &[u8] HOT 2
- Improve performance of Reader get_named HOT 4
- 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 1
- 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
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.