interface StreamParserObject<Result> {
- function eof(rest:ChunkCursor):Outcome<Result, Error>;
+ function eof(rest:ChunkCursor):Outcome<Option<Result>, Error>;
}
Rationale: an eof of a stream might come "detached" from any data. For example for signal stream the Data and End signal are always separated. In that case, there could be no data to process (if the previous chunks are complete and already get emitted) and thus no result to emit in eof() and the current API is unable to express that.
Breaking change: added function readEof():Outcome<Option<Result>, Error> to BytewiseParser and the eof is no longer handled with a -1 byte.
At the same time, I updated/simplified Splitter implementation to use ChunkCursor::seek
Before this PR, the way to work is to wrap every result in an extra Option so that one can emit None in eof. I believe this change can eliminate these extra allocations.
Mainly changed the following:
Rationale: an eof of a stream might come "detached" from any data. For example for signal stream the
Data
andEnd
signal are always separated. In that case, there could be no data to process (if the previous chunks are complete and already get emitted) and thus no result to emit ineof()
and the current API is unable to express that.Breaking change: added
function readEof():Outcome<Option<Result>, Error>
to BytewiseParser and the eof is no longer handled with a-1
byte.At the same time, I updated/simplified
Splitter
implementation to useChunkCursor::seek