I develop on a platform using a custom cooperative task queue and very little memory.
I'd like to decode a largeish protobuf that consists of a few levels of nested repeated submessages, and do it with a minimal of copy buffers. At the bottom of these nests, the data is used to kick off some longer-running activities, like use of a serial port of crypto engine.
Right now I have been experimenting with using callbacks that call callbacks, and at the bottom, rather than copy the bytes into some struct, the function "does something" with those bytes. Typically, those functions will themselves take a completion callback as an argument, but because I am walking a tree I don't have any easy way to pop out and return; I have to wait for the leaf task to complete before decoding the next.
Is there a natural way with nanopb to get a behavior where the pb_decode() function only advances one field through the protobuf and return a pointer to the next thing to decode, rather than running through to completion?
Does that even make sense?
Best,
Dave J