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

Streaming Encoder/Decoder #8

Merged
merged 8 commits into from
Mar 4, 2019
Merged

Conversation

jamesmunns
Copy link
Owner

Closes #5. Should work even for no_std targets!


/// Complete encoding of the output message. Does NOT terminate
/// the message with the sentinel value
pub fn finalize(self) -> Result<usize, ()> {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awelkie do you think that the finalize() method should insert the final 0x00? I don't think I did this, as it didn't match your current API, but IMO it makes sense to do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good question. I didn't insert 0x00 at the beginning or the end to let the user decide where to insert the sentinel. I figure there may be systems where the user would want to insert the sentinel at the beginning of the frame and not the end, or vice-versa, or maybe both, so I just avoided making that decision.

I'd prefer to keep it that way, but I also realize that in nearly every situation one would want to insert the sentinel at the end, so I'm open to debate.

src/lib.rs Show resolved Hide resolved
James Munns added 2 commits March 1, 2019 17:21
handle case where destination buffer is exactly enough to handle
the encoded message
@jamesmunns
Copy link
Owner Author

Okay, I'm done with messing with this PR now, let me know if you have any questions!

@awelkie
Copy link
Collaborator

awelkie commented Mar 4, 2019

LGTM. Ideally I think the streaming decoder would allow streaming the output as well, instead of placing the output in a buffer. So with every input byte the decoder would return zero or one output bytes, and the user could consume the output in a streaming manner. But this PR works and is an improvement to the API so I'll merge it.

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.

2 participants