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

Derive common traits for NamedPipeInfo struct #6586

Merged
merged 2 commits into from
May 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tokio/src/net/windows/named_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ pub enum PipeEnd {
/// Information about a named pipe.
///
/// Constructed through [`NamedPipeServer::info`] or [`NamedPipeClient::info`].
#[derive(Debug)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct PipeInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

This type is #[non_exhaustive] so that we can add additional fields in the future. Adding Copy goes against that since it prevents the addition of non-copy fields in the future.

The same could apply to the other traits, but in a lesser extent.

Copy link
Contributor Author

@Tacklebox Tacklebox May 25, 2024

Choose a reason for hiding this comment

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

Since this is only constructed from calling NamedPipe[Server|Client]::info() and those are convenience methods to call GetNamedPipeInfo, I wouldn't expect tokio to ever return a different substantially different struct than the one from the win32 api. With that in mind, I don't think #[non_exhaustive] is super useful here.

But if that's a dealbreaker, would this change be acceptable without Copy? Or at least with only the addition of Clone?

Copy link
Contributor

Choose a reason for hiding this comment

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

OS apis such as GetNamedPipeInfo are sometimes extended to return additional data in newer versions of the OS.

The change is acceptable with just Clone.

/// Indicates the mode of a named pipe.
Expand Down
Loading