Add a std IO protocol interface#125
Conversation
43bd048 to
cac6368
Compare
| /// Extract the packet type from the header byte. | ||
| pub fn packet_type(&self) -> PacketType { | ||
| self.packet_type | ||
| PacketType::from_byte(&self.data[0]) |
There was a problem hiding this comment.
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.
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
Protocolinterface. Also experiments with some new API refactors which could be good for the existing async version.