Open
Description
When parsing a protocol chunk by chunk, we need to stop successfully with every thing we decoded so far, and keep the remaining bytes for later.
The current decoder API provides no way to do such a thing.
Two examples of what I need to do when parsing the NATS protocol in Elm Nats:
- a decoder that read a string up to a delimiter or the end of content. When parsing a message, if the end of line is found then the message is complete. If not, I want to get everything up to the end of the bytes, and keep it for later.
- a decoder that reads up to N bytes. This is for reading a binary payload: I know the payload size, but it may not be complete. If not, I need to keep it for later.
To workaround this I need to have multiple decode phases, cut the bytes to decode the tail, and I get a complicated recursive function instead of a single Decoder.
Metadata
Metadata
Assignees
Labels
No labels