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 BufStream::with_capacity #2125

Merged
merged 1 commit into from
Jan 21, 2020
Merged

io: add BufStream::with_capacity #2125

merged 1 commit into from
Jan 21, 2020

Conversation

vitorenesduarte
Copy link
Contributor

Motivation

Currently it's not possible to configure the buffer size when creating a BufStream.
I'm using BufStream to wrap a TcpStream and having totokio::io::split it and pass each half to BufReader::with_capacity and BufWriter::with_capacity seems sub-optimal.

Solution

This PR adds a BufStream::with_capacity method that takes as input both the capacity of the read buffer and the capacity of the write buffer.
Not sure if this is the best API, but it seemed more flexible than having a single capacity as input.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@LucioFranco LucioFranco merged commit 3176d0a into tokio-rs:master Jan 21, 2020
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.

None yet

2 participants