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 #4120

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

This should resolve #4098

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Sep 20, 2021
@Noah-Kennedy
Copy link
Contributor Author

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.

@Darksonn
Copy link
Contributor

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

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

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

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

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

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn merged commit d9ca151 into tokio-rs:master Sep 25, 2021
suikammd pushed a commit to suikammd/tokio that referenced this pull request Oct 7, 2021
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-net Module: tokio/net
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add readable/writeable/ready methods to read/write half
2 participants