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

io: add a CopyBuffer::with_size method #3726

Closed
wants to merge 3 commits into from

Conversation

aym-v
Copy link

@aym-v aym-v commented Apr 24, 2021

This PR is a proposal to close #3722.
It adds a new CopyBuffer::with_size method which allows users to set the size of the buffer if the default size of 2048 is inadequate.

@taiki-e
Copy link
Member

taiki-e commented Apr 28, 2021

This PR is a proposal to close #3722.
It adds a new CopyBuffer::with_size method which allows users to set the size of the buffer if the default size of 2048 is inadequate.

What this PR adds is a method on a private type, so users will not be able to specify buffer size yet.
To implement the functionality proposed by #3722, I think you have to add a new public function like #3572.

@taiki-e taiki-e added A-tokio Area: The main tokio crate M-io Module: tokio/io labels Apr 28, 2021
@aym-v
Copy link
Author

aym-v commented Apr 28, 2021

@taiki-e Thank you for your help, a public method is now exposed with the latest commit

@rneswold
Copy link

With each new release of tokio, I keep hoping to find this feature added. Is there a plan to add this soon?

@taiki-e
Copy link
Member

taiki-e commented Jul 26, 2021

@rneswold As said in #3722, the current implementation of this PR is equivalent to copy_buf + BufReader.

let mut reader = BufReader::with_capacity(size, reader);
copy_buf(&mut reader, &mut writer).await?;

Given that equivalent code is already available on the released versions, this feature request is not necessarily a high priority, and I think it would be better to have a discussion about alternative implementation before merging this.

@Darksonn Darksonn closed this Apr 16, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add new method for io::copy that take buffer size
4 participants