Re: [capnproto] Copying existing struct into request params

2021-06-09 Thread Vaci
Thanks for the explanation on the interaction between schema evolution and copying structures, that makes sense. It may not be a common requirement to want to copy over the entire request structure, rather than just initialise a member from an existing reader. For the moment, I only care about

Re: [capnproto] Copying existing struct into request params

2021-06-04 Thread 'Kenton Varda' via Cap'n Proto
I see. There isn't a great API for this right now. The problem is, once a struct Builder is already allocated, the struct can't be resized. But if you're trying to copy the content of another struct into it, it's possible that other struct was originally created with a newer version of the schema w

Re: [capnproto] Copying existing struct into request params

2021-06-03 Thread Vaci
Ah, I figured out that I can use the layered API to decode each item in the list individually: Bar::Client cap; kj::ArrayPtr text; capnp::MallocMessageBuilder mb; capnp::JsonCodec codec; kj::ArrayBuilder> promises; auto value = mb.initRoot(); codec.decodeRaw(text, val

Re: [capnproto] Copying existing struct into request params

2021-06-03 Thread Vaci
That's not quite what I want to do. Given that a request is a struct type, I want to copy or assign an existing struct to the whole request. I can use the json decoder to write content into the request struct, but I don't see a way to do that when I'm holding an orphan pointer to a struct that

Re: [capnproto] Copying existing struct into request params

2021-06-02 Thread 'Kenton Varda' via Cap'n Proto
Hi Vaci, An RPC request is always a struct type, not a list, so I assume what you really mean here is that you want to use the list as a field of the request? E.g. you have: struct Foo {} interface Bar { foo @0 (foos :List(Foo)); } Then you would do: auto req = bar.fooRequest(); auto orpha