wayland-rs
wayland-rs copied to clipboard
Why `wl_pointer::Event` is not `Copy` or `Clone`
I'm piping the event to a broadcast channel, it'd be really handy if the event implements Clone
.
I checked the source code and didn't see anything preventing that. Am I missing something?
I don't think there is anything strictly preventing the event/request enums from being Clone
indeed, the only point that would require some care is for messages that contain a RawFd
, as cloning them mindlessly may cause some unexpected bugs.
Note that FromRawFd::from_raw_fd is already unsafe, so cloning the fd
is likely "not unsafe".
That said, pointer events don't pass any file descriptors, you're probably thinking of keyboard events.
That said, pointer events don't pass any file descriptors, you're probably thinking of keyboard events.
Well, I'm thinking about all events. As this code is auto-generated by wayland-scanner
it's kind of an all-or-nothing situation, either all event enums are Clone
, or none are.
Wayland-rs now generates Event
enums with OwnedFd
instead of RawFd
, so it's definitely not possible to derive clone in that case.
Wayland-scanner could add Clone
only if all events could be cloned, but that would be a backwards compat issue if a new protocol version added an event with an fd.
But I don't think there's any reason you can't use something like Arc<wl_pointer::Event>
and send that over a broadcast channel.
So this doesn't really seem viable or necessary. As far as I can tell.