Hi Filip,
You can copy a struct from one message to another like:
outgoingRequestBuilder.setMsg(incomingRequestReader.getMsg());
There isn't a way to do this without a copy, since the contents of the
specific struct may be interleaved with other data in the message.
-Kenton
On Thu, May 7, 2020 at 3:52 AM Filip Haglund <[email protected]>
wrote:
> Is the pragmatic approach to store one capnp msg inside a `Data` field of
> another here?
>
> On Wednesday, May 6, 2020 at 11:37:57 PM UTC+2, Filip Haglund wrote:
>>
>> 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 @1 :Msg;
>> }
>>
>> 2. store that `Msg` field in a db
>>
>> 3. read the `Msg` field back from the db and wrap it in this type and
>> send it on:
>>
>> struct OutgoingRequest {
>> action @0 :Text;
>> critical @1 :Bool;
>> msg @2 :Msg;
>> }
>>
>> I'm using the go v2 and d libraries, in case that matters.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/capnproto/39efb5e7-f91b-4156-b5ed-5320fa8c90c2%40googlegroups.com
> <https://groups.google.com/d/msgid/capnproto/39efb5e7-f91b-4156-b5ed-5320fa8c90c2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/capnproto/CAJouXQk4_AmcPEBhUnJB0GxbF7yb-p3w7sOZbB2S3k3Vx4mT8g%40mail.gmail.com.