-
Notifications
You must be signed in to change notification settings - Fork 5
Add a std IO protocol interface #125
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
Conversation
43bd048
to
cac6368
Compare
pub fn packet_type(&self) -> PacketType { | ||
self.packet_type | ||
PacketType::from_byte(&self.data[0]) |
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.
Both of these will panic for an empty payload. Not sure if that is possible or not, but pointing it out for reference.
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.
Oops good point, shoulda thought more about this change.
Overall looks good and I like the new flow. Would just have to think for a while if someone could somehow send an empty payload contents, in which case |
I think it would be difficult to not send a header byte, but still feels like this should be more defensive. |
Could someone just send |
I think that is against the spec because a header byte and a 16 byte tag are required. But a bug in a client or a bad actor could send it anyways. Right now, that case specifcally is handled by this impl in the low level |
Packet payloads should always include a header byte according to the spec, but check that it actually does to better handle buggy clients or bad actors.
Interesting we didn't run into this scenario before. I think everything checks out though. All cases abuse should now lead to an EOF if I'm understanding correctly. |
Add a std library I/O (aka blocking) high level
Protocol
interface. Also experiments with some new API refactors which could be good for the existing async version.