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 try_*, readable, writable, ready, and peer_addr methods to TCP and Unix split halves

Merged
merged 11 commits into from Sep 25, 2021
Merged

Add try_*, readable, writable, ready, and peer_addr methods to TCP and Unix split halves #4120

merged 11 commits into from Sep 25, 2021

Conversation

Noah-Kennedy
Copy link
Contributor

@Noah-Kennedy Noah-Kennedy commented Sep 19, 2021

Motivation

Currently, Tokio's split halves APIs leave out a lot of fairly useful methods from TcpStream and UnixStream.

Solution

This PR adds the try_*, readable, writable, ready, and peer_addr methods to the split halves APIs for TcpStream and UnixStream.

This PR also adds a doc example for the UnixStream-related peer_addr methods.

Closes: #4098

…d unix split halves

Also adds a doc test to UnixStream::peer_addr().
@Noah-Kennedy
Copy link
Contributor Author

Noah-Kennedy commented Sep 19, 2021

This should resolve #4098

@Darksonn Darksonn added A-tokio M-net labels Sep 20, 2021
@Noah-Kennedy
Copy link
Contributor Author

Noah-Kennedy commented Sep 20, 2021

I decided it wouldn't make a ton of sense not to just add the local_addr method as well, since I'm already adding peer_addr.

tokio/src/net/unix/stream.rs Outdated Show resolved Hide resolved
tokio/src/net/tcp/split.rs Outdated Show resolved Hide resolved
tokio/src/net/tcp/split.rs Outdated Show resolved Hide resolved
@Darksonn
Copy link
Contributor

Darksonn commented Sep 20, 2021

Honestly, now that I see how massive this change is, I wonder if we should change course and instead write some documentation that explains how you can call methods on the underlying IO resource.

@Darksonn
Copy link
Contributor

Darksonn commented Sep 20, 2021

Every time we've added a new try_* like method, it has to go on every single type that has this family of functions, and it's already a lot of work to add it given the ones we have now.

@Noah-Kennedy
Copy link
Contributor Author

Noah-Kennedy commented Sep 20, 2021

I've removed the examples, it's no longer nearly as large of a change

Noah-Kennedy and others added 2 commits Sep 25, 2021
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
@Noah-Kennedy
Copy link
Contributor Author

Noah-Kennedy commented Sep 25, 2021

@Darksonn I've gone through and addressed the documentation issues.

tokio/src/net/tcp/split.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Darksonn Darksonn left a comment

Thanks.

@Darksonn Darksonn merged commit d9ca151 into tokio-rs:master Sep 25, 2021
27 checks passed
suikammd pushed a commit to suikammd/tokio that referenced this issue Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio M-net
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants