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_write to TcpStream #176

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Add try_write to TcpStream #176

merged 5 commits into from
Jul 15, 2024

Conversation

brandonpike
Copy link
Contributor

Add TcpStream::try_write() and WriteHalf::try_write().

These allow for a result-based synchronous write attempt.

Signed-off-by: Brandon Pike <[email protected]>
Copy link
Contributor

@mcches mcches left a comment

Choose a reason for hiding this comment

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

Lgtm, please add a test that hits this method.

/// # Return
///
/// If data is successfully written, `Ok(n)` is returned, where `n` is the
/// number of bytes written. If the stream has been shut down
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd just copy the doc verbatim. In future changes this will do what the tokio flavor does and then we don't need to update the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed this nit. You're probably right, although I see some (small) benefit in the doc representing the current state

@mcches mcches merged commit 0c984a0 into tokio-rs:main Jul 15, 2024
3 checks passed
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.

2 participants