Skip to content

Conversation

mkroening
Copy link

@mkroening mkroening commented Sep 4, 2025

This PR implements both sync and async versions of Read, BufRead, and Write, as well as ReadReady and WriteReady for VecDeque<u8> by adapting the corresponding implementations from std.

@mkroening mkroening requested a review from a team as a code owner September 4, 2025 09:11
@mkroening mkroening changed the title feat: implement Read, BufRead, and Write for VecDeque<u8> feat: implement Read, ReadReady, BufRead, Write, and WriteReady for VecDeque<u8> Sep 5, 2025
@mkroening mkroening changed the title feat: implement Read, ReadReady, BufRead, Write, and WriteReady for VecDeque<u8> feat(io): implement Read, ReadReady, BufRead, Write, and WriteReady for VecDeque<u8> Sep 24, 2025
@mkroening mkroening mentioned this pull request Sep 24, 2025
3 tasks
Copy link
Contributor

@chrysn chrysn left a 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>> {
Copy link
Contributor

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?

Copy link
Author

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.
Copy link
Contributor

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> {
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I am aware of that. This is how I discovered the mismatch in requirements that's being discussed in #696.

I am happy to remove this if the maintainers are okay with moving forward with this PR before deciding on #696.

@mkroening
Copy link
Author

Thanks for the external review! :)

The commits look a bit messy – was the intention to split them up between the sync and the async part?

No, the intention was to separate concerns:

  1. Raise the embedde-io-async MSRV as required by the changes and implied through depending on embedded-io anyhow.
  2. Implement I/O traits by adapting code from std.
  3. Implement additional traits that are not present in std.

@chrysn
Copy link
Contributor

chrysn commented Sep 25, 2025

Thanks; then all is fine with me.

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