pycapnp: Reading and Writing a List without custom capnp file

670 Views Asked by At

I have read through the pycapnp quickstart and docs, and I see no mention for how to read and write basic list objects (like a list of floats).

In particular, I am aware that if I write a custom type in a capnp file, then I can read an object of that type using something like

addressbook_capnp.Person.from_bytes(encoded_message)

What I would like to know is the syntax for reading a list of floats like this. I imagine that it would look something like

capnp.List.Float64.from_bytes(encoded_message)

But I simply can't find the correct syntax. Furthermore, since Capn Proto does not export aliases from the .capnp file, I cannot just define a list of floats there (or so it seems).

Can somebody please tell me the correct syntax for reading, writing, and creating lists of basic objects in pycapnp?


EDIT:

For example, in C++ I can create a list object (without a custom type) like this:

::capnp::MallocMessageBuilder message; 
auto capnp_point_cloud = message.initRoot<::capnp::List<Val>>(num_axes);
for (size_t i = 0; i < num_axes; ++i) { 
    capnp_point_cloud.set(i, array[i]);
}
0

There are 0 best solutions below