Skip to content
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

Add an "advance" function for the iovec type. #1637

Closed
notgull opened this issue Jan 19, 2022 · 2 comments · Fixed by #1643
Closed

Add an "advance" function for the iovec type. #1637

notgull opened this issue Jan 19, 2022 · 2 comments · Fixed by #1643

Comments

@notgull
Copy link
Contributor

notgull commented Jan 19, 2022

In Rust's standard library, the IoSlice type has methods "advance" and "advance_slices", which are used to "advance" the slices by a set number of bytes. This is usually done in response to a read_vectored call.

However, the iovec type, necessary for the [read/write]v and [send/recv]msg calls, does not have an equivalent pair of functions. This makes it difficult to call, say readv in such a way that you can be sure that all of the bytes have been written.

If there is interest in this, I am willing to write a pull request for it.

@asomers
Copy link
Member

asomers commented Jan 22, 2022

Now that std has a vectored I/O API, I think it would be a VERY GOOD IDEA for Nix to follow that API as closely as possible. To that end, I suggest we simply replace nix:::sys::uio::IoVec with std::io::IoSlice. They're practically identical, after all. To ease transition, we can reexport IoSlice for a release or two. Would you be willing to submit a PR?

@notgull
Copy link
Contributor Author

notgull commented Jan 22, 2022

Yes, I am willing to submit a PR.

bors bot added a commit that referenced this issue Apr 8, 2022
1643: Replace the IoVec struct with IoSlice and IoSliceMut from the standard library r=asomers a=notgull

As per discussion in #1637, the `IoVec<&[u8]>` and `IoVec<&mut [u8]>` types have been replaced with `std::io::IoSlice` and `IoSliceMut`, respectively. Notable changes made in this pull request include:

- The complete replacement of `IoVec` with `IoSlice*` types in both public API, private API, and tests.
- Replacing `IoVec` with `IoSlice` in docs.
- Replacing `&[IoVec<&mut [u8]>]` with `&mut [IoSliceMut]`, note that the slice requires a mutable reference now. This is how it's done in the standard library, and there might be a soundness issue in doing it the other way.

Resolves #1637 

Co-authored-by: not_a_seagull <notaseagull048@gmail.com>
@bors bors bot closed this as completed in #1643 Apr 8, 2022
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 a pull request may close this issue.

2 participants