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 is of the same type as the request.

Vaci

On Wednesday, 2 June 2021 at 15:36:55 UTC+1 ken...@cloudflare.com wrote:

> 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 orphanage = capnp::Orphanage::getForMessageContaining(req);
>
> auto orphan = json.decode<capnp::List<Foo>>(txt, orphanage);
>
> req.adoptFoos(kj::mv(orphan));
>
>
> -Kenton
>
> On Wed, Jun 2, 2021 at 6:29 AM Vaci <va...@vaci.org> wrote:
>
>> I may be missing something obvious, but is it possible to copy the 
>> content of a struct into the body of a request builder?
>>
>> I have an interface of the form:
>>
>>    struct Foo {};
>>
>>   interface Bar {
>>      foo @0 Foo;
>>   };
>>
>> I want to import a bunch of Foo structures using the json reader and use 
>> them to populate the requests. This works fine with a single item, because 
>> I can just decode directly into the request body:
>>
>> auto foo = bar.fooRequest();
>> capnp::JsonCodec json;
>> json.decode(txt, foo);
>>
>> ...but if my input is a list of items, the json decoder will return an 
>> (orphaned) list of Foo structures, and I can't see a way to use each item 
>> as request params.
>>
>> Vaci
>>
>>
>>
>>
>>
>>
>>
>> -- 
>> 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 capnproto+...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/capnproto/55a2f540-cece-474f-8795-b65e15f024e1n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/capnproto/55a2f540-cece-474f-8795-b65e15f024e1n%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 capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/406e48f0-0688-4691-b619-4d523ed2b959n%40googlegroups.com.

Reply via email to