Re: [capnproto] How to get the serialized length of a message?

2020-05-06 Thread Vitali Lovich
That’s fair. I’m having some corruption issues so I’m trying to layer a framing message around cap’n’proto that has the length of the payload (+ checksums) which is where the length in bytes comes in useful. On Wed, May 6, 2020 at 3:07 PM Kenton Varda wrote: > Eh, I like having the APIs be in wo

Re: [capnproto] How to get the serialized length of a message?

2020-05-06 Thread 'Kenton Varda' via Cap'n Proto
Eh, I like having the APIs be in words in hopes that it reminds people to think about alignment. When allocating space for a capnp message, you should always allocate an array of words, not an array of bytes. Seems not too hard for the caller to multiply by sizeof(capnp::word) if needed? -Kenton

Re: [capnproto] How to get the serialized length of a message?

2020-05-06 Thread Vitali Lovich
The optometrist tells me I have 20/20 vision but I think it must clearly be a lie at this point :). Any objection to a contribution to return the size in bytes? On Wed, May 6, 2020 at 2:29 PM Kenton Varda wrote: > I think this is what you want: > > > https://github.com/capnproto/capnproto/blob/3

[capnproto] How do I serialize/deserialize part of a message?

2020-05-06 Thread Filip Haglund
I have an api that speaks capnp. I want to store a subset of the incoming message (a specific field) in a db and pass it onwards inside other messages later on. How can I do this? Here's a rough sketch of events in order: 1. incoming request: struct IncomingRequest { dbid @0 :Text; msg

Re: [capnproto] How to get the serialized length of a message?

2020-05-06 Thread 'Kenton Varda' via Cap'n Proto
I think this is what you want: https://github.com/capnproto/capnproto/blob/3f0fee61c65475c8debfdf8c01f96c2f7e7eeb14/c++/src/capnp/serialize.h#L102 :) -Kenton On Wed, May 6, 2020 at 2:54 PM wrote: > Is there a convenient way to peek at the size a message will take up on > the wire? My thinking

[capnproto] How to get the serialized length of a message?

2020-05-06 Thread vlovich
Is there a convenient way to peek at the size a message will take up on the wire? My thinking is to create a custom output stream that I `capnp::writeMessage` to that just sums everything but I feel like this could be done more efficiently within capn'n'proto, just couldn't find anything like t