Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StreamParserObject::eof returns an Option #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kevinresol
Copy link
Member

@kevinresol kevinresol commented Jun 18, 2021

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
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