Description
Hello!
I am currently trying to build some helper to append to an arbitrary list.
In order to do that, I am relying on dynamic_value, dynamic_struct and dynamic_list modules.
The algorithm is roughly the following:
- Access the list within the message walking the tree of dynamic_struct until the list is found
- Save the list into another temporarily message/builder
- Create a new list with N+1 element
- Copy each element from the saved list at 2.
- Write the new element at index N
The problem is that step 4: I haven't been able to find a way to get back dynamic_list::Reader from a message::Reader.
In order to deeply copy the list, here is what I am trying to do:
let dynamic_list_reader = <...>;
let mut saved_list_builder = capnp::message::Builder::default();
saved_list_builder.set_root(dynamic_list_reader).unwrap();
I would like to be able to do something like:
let saved_list_reader = saved_list_builder.get_root_as_reader::<dynamic_list::Reader>().unwrap();
So that I can copy each element of that list into the new list in the initial builder.
Is what am trying even make sense? I believe implementing FromPointerReader
for dynamic_list::Reader
should allow me to do what I need but I am not sure if it would be safe / sound to do?
In any case, thank you for your help 👍