-
Notifications
You must be signed in to change notification settings - Fork 246
feat(io): implement Read
, ReadReady
, BufRead
, Write
, and WriteReady
for VecDeque<u8>
#697
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
base: master
Are you sure you want to change the base?
Conversation
This is the same MSRV as embedded-io, which embedded-io-async depends on.
300c8b1
to
e72721f
Compare
38683cb
to
ad6a7d1
Compare
Read
, BufRead
, and Write
for VecDeque<u8>
Read
, ReadReady
, BufRead
, Write
, and WriteReady
for VecDeque<u8>
Read
, ReadReady
, BufRead
, Write
, and WriteReady
for VecDeque<u8>
Read
, ReadReady
, BufRead
, Write
, and WriteReady
for VecDeque<u8>
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.
Generally I think it's good to have those provided, and the code does that.
The commits look a bit messy – was the intention to split them up between the sync and the async part?
The code looks good to me; several comments, but some are more for documenting that a part was checked (just mark them as resolved if you don't want to add anything). Those where I do suggest changes are all minor, so feel free to change things or not.
(Also, I'm just a guest contributor here, just trying to make it easier to get this merged).
} | ||
|
||
#[inline] | ||
async fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ReadExactError<Self::Error>> { |
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.
This looks like it's more code than the read above combined with the provided read_exactly – is there really a point to spelling this out over letting the compiler assemble the provided one?
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.
Apparently, yes. I did not reevaluate this code coming from std
, but it was a conscious decision to specialize it: rust-lang/rust#132039
@@ -0,0 +1,83 @@ | |||
//! Adapted from std. |
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.
It's pretty verbatim in places. I think that's fine given that both are licensed under "MIT OR Apache-2.0", and the original files do not have any copyright notes that point out concrete contributors (so the embedded-hal copyright notice should already cover that).
} | ||
|
||
#[inline] | ||
async fn flush(&mut self) -> Result<(), Self::Error> { |
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.
This is redundant with the provided method.
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.
Thanks for the external review! :)
No, the intention was to separate concerns:
|
Thanks; then all is fine with me. |
This PR implements both sync and async versions of
Read
,BufRead
, andWrite
, as well asReadReady
andWriteReady
forVecDeque<u8>
by adapting the corresponding implementations fromstd
.