Closed jonas-schievink closed 5 years ago
Yeah, so, this is a relic from when I initially envisioned them maybe being used like EvdevHandle(&file).driver_version()?
, like a transient wrapper that higher level abstractions might use. It's silly and makes no sense, and I was too lazy to add a phantom lifetime to the type to boot.
This is also the only way to interface with the crate at the moment, and although I still intend to include nicer interfaces on top of them eventually, I agree that ownership in some way would be appropriate.
Currently,
EvdevHandle
relies on the user keeping the original file descriptor open while it's alive. This is very odd, since no fd wrapper instd
requires this and it requires storing 2 objects instead of just theEvdevHandle
.I think it would be a good idea to instead take ownership of the
RawFd
and close it on drop. Additionally,EvdevHandle
could implementAsRawFd
(andIntoRawFd
) to accomodate existing uses where the fd is shared (are there any?). Users could alsodup
the fd before creating theEvdevHandle
if they really require shared access to the fd.What do you think?