Skip to content

StreamParserObject::eof returns an Option - #46

Open
kevinresol wants to merge 2 commits into
masterfrom
eof_option
Open

StreamParserObject::eof returns an Option#46
kevinresol wants to merge 2 commits into
masterfrom
eof_option

Conversation

@kevinresol

@kevinresol kevinresol commented Jun 18, 2021

Copy link
Copy Markdown
Member

Mainly changed the following:

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

@kevinresol

Copy link
Copy Markdown
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant