-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streaming encoding on the fly #165
Comments
No, it's not possible with the current interface. I can imagine adding a streaming mode at some point. It would have to work only with indefinite length maps and arrays. Some sort of flush API would be added. I will leave this open and mark it as a feature enhancement to add some day. It won't be anytime soon as the list is pretty long. |
Um, not necessary. I suppose the difficulty of encoding sized map/arrays is that size bytes are encoded before array/map items and could vary in size themselves so you have to keep that whole array in memory before flushing in order to fill introduction bytes and possibly shift data if element count is big. But you can workaround that by providing a function that opens sized array but requires array size argument. Then it's programmers responsibility to provide exactly N elements before calling array close function. You also should be able to track that cheaply with counter variable for error detecting. |
Yes, you are right. And doing that will require an API change for QCBOR arrays and maps. Thx for correcting that. |
Yes, this is the approach I reccomend. I've been able to create a simplified scenario of streaming array with QCBOR. But, as I wrote, this works in my project but the API is quite ugly. |
I don't know if this is possible or not.
I have a fixed size array of data
float data[100];
and I need to encode it in CBOR and send the encoded CBOR.
I know how to use QCBOR to generate a large encoded UsefulBuf (in memory) and then iterate over it to send byte after byte.
Is there a way to use QCBOR to encode the array on the fly and to send out the data without having the large encoded UsefulBuf in memory?
For other CBOR library I see streaming.
The text was updated successfully, but these errors were encountered: