-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
|
||
/// Complete encoding of the output message. Does NOT terminate | ||
/// the message with the sentinel value | ||
pub fn finalize(self) -> Result<usize, ()> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
handle case where destination buffer is exactly enough to handle the encoded message
Okay, I'm done with messing with this PR now, let me know if you have any questions! |
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. |
Closes #5. Should work even for no_std targets!