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 AsyncWriteExt::write_all_vectored #3679

Open
davidpdrsn opened this issue Apr 5, 2021 · 6 comments
Open

Add AsyncWriteExt::write_all_vectored #3679

davidpdrsn opened this issue Apr 5, 2021 · 6 comments
Labels
A-tokio Area: The main tokio crate M-io Module: tokio/io S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.

Comments

@davidpdrsn
Copy link
Member

In #3678 we added AsyncWriteExt::write_vectored. It would be nice to also provide AsyncWriteExt::write_all_vectored that writes all the data similarly to std::io::Write::write_all_vectored.

@davidpdrsn davidpdrsn added E-help-wanted Call for participation: Help is requested to fix this issue. A-tokio Area: The main tokio crate M-io Module: tokio/io E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Apr 5, 2021
@davidpdrsn davidpdrsn removed E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Apr 6, 2021
@davidpdrsn
Copy link
Member Author

This should wait for std::io::Write to stabilize as we want to mirror the API.

The implementation will probably also use on IoSlice::advance which is also unstable.

@taiki-e taiki-e added the S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work. label Apr 7, 2021
@Tnze
Copy link

Tnze commented Dec 10, 2023

Is there any workaround? How could we manually use write_vectored to ensure write all data?

@Darksonn
Copy link
Contributor

Manually? You can call it in a loop.

@Tnze
Copy link

Tnze commented Dec 10, 2023

Manually? You can call it in a loop.

Actually, no. Because if the first call doesn't finish the work, you can't write starting at the latest position in the second call.

@Darksonn
Copy link
Contributor

You have to update the slice to skip the bytes at the start. You can use IoSlice::advance_slices to do that. The method is unstable, but you can copy its implementation to do it on stable Rust.

@Arnavion
Copy link
Contributor

Arnavion commented Sep 5, 2024

IoSlice{,Mut}::advance{,_slices} are now stable in 1.81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-io Module: tokio/io S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.
Projects
None yet
Development

No branches or pull requests

5 participants