-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
When using CoAP block-wise transfer, it is a common and useful pattern to encode output into a block-sized buffer and discard anything written outside these bounds. (windowed-infinity does that for serde_cbor, ciborium and minicbor). A good entry point into this are write traits such as embedded-io's Write.
tps_minicbor currently doesn't support these for two reasons:
- The constructor of CBORBuilder takes precisely a (full-length) slice.
- move_items won't work with this when data would be moved from the discard-area to the buffer-area.
- (windowed-infinity generally expect to be written linearly, but that's not a hard requirement)
So, what are options to use tps_minicbor with that pattern?
- Always know the number of items in advance. Maybe using blocks would only work with encoders that (type-wise) pledge to always know their numbers (or have bounds on their numbers that don't span encoding bins).
- Assume the worst (possibly guided by bounds) and encode in a larger than the smallest representation. (Might also be aided by extra bounds on the encoded types, lest they expect the canonical encoding).
- Is there a limit to how far things could be rotated, so that a moderately larger buffer would suffice? Maximum lengths are 64bit, so we'd only need about 8 extra bytes. There can be multiple parallel
EncodeContexts, each of which may shift by 8, ... so maybe the EncodeContext provides its own buffer? (This might be a bit hairy, but it might just work).
First question should probably be: Is that a pattern you'd like to accommodate?
Metadata
Metadata
Assignees
Labels
No labels