Re: [capnproto] Selecting the correct message type?

2021-07-17 Thread 'Kenton Varda' via Cap'n Proto
There is no way to find out a message's type if you don't know it already. So, you'll need to arrange to communicate the type yourself. The easiest way is to write an "envelope" message that is a union of all your other messages. struct OuterMessage { union { foo @0 :FooMessage; bar @1

Re: [capnproto] How to align capnproto data to architectures word size?

2021-07-17 Thread SR D
Thank you. On Saturday, July 17, 2021 at 10:04:01 AM UTC-5 ken...@cloudflare.com wrote: > Ideally, you'd update the implementation of `getBuff()` so that it > allocates an aligned buffer. Note that malloc() always returns aligned > buffers, so if you can make it so that the pointer returned by

[capnproto] Selecting the correct message type?

2021-07-17 Thread SR D
If the sender is sending any number of different data types that have been serialized across the network, how does one know which type is coming in so that it can be pulled off using FlatArrayMessageReader's::getRoot<>? E.g., say this while loop is constantly reading serialized data from the

Re: [capnproto] How to align capnproto data to architectures word size?

2021-07-17 Thread 'Kenton Varda' via Cap'n Proto
Ideally, you'd update the implementation of `getBuff()` so that it allocates an aligned buffer. Note that malloc() always returns aligned buffers, so if you can make it so that the pointer returned by getBuff() is one that was allocated directly by malloc(), then it should work. Probably, though,