When the PacketParser encounters junk, it returns an error without emitting the last successfully parsed packet
Consider a packet sequence followed by some junk (say a NUL
byte). When the PacketParser::parse
encounters the NUL
byte, it returns an error, which PacketParser::next
propagates without emitting the last successfully buffered packet (note the ?
at the end of that line).
It would be better if the packet was first returned or returned with the error. Unfortunately, we can't add a new variant to PacketParserResult
, as it is not non-exhaustive. We also can't use PacketParser::Success
as-is as there is no buffered packet. Although we could fake it, by using say a marker packet, which has to be ignored. Thoughts?