Derive common traits for NamedPipeInfo struct#6586
Derive common traits for NamedPipeInfo struct#6586Darksonn merged 2 commits intotokio-rs:masterfrom Tacklebox:named_pipe_derives
Conversation
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
| #[non_exhaustive] | ||
| pub struct PipeInfo { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Motivation
I would like to use windows named pipes as the transport for GRPC with tonic. That requires that the transport implement Connected, which requires the info struct implement Clone. While a wrapper struct could be used, NamedPipeInfo doesn't seem to have any particular reason not to implement Clone directly.
Solution
Add Clone (And a few other useful traits already derived on the members of NamedPipeInfo) to the derive macro.