-
Notifications
You must be signed in to change notification settings - Fork 53
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
Use i32
in SystemError::Unknown
instead of nix
Errno
#173
Conversation
This way users of `drm` can match on constants from `libc`, or can convert it to the error types from any version of `nix` or `rustix`. This addresses a bit of awkwardness in Smithay/smithay#1162 and rust-windowing/softbuffer#164. This should eliminate nix as a "public dependency" of `drm`, though it's still exposed by `drm-ffi`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe std::io::Error
would be better?
Perhaps. It looks like it is possible to losslessly convert to an |
Could we make the entire struct That way people can easily convert it into whatever format they want. |
Indeed, if this is "just wrapping I'm not seeing why the unwrap is necessary: |
It wouldn't be possible to make it a Rustix's |
It looks like
I mean if the user of the library wants to handle the error, it may need to call The concern about matching on the error being awkward is reduced if the whole |
I guess one would defer to Indeed, if there are non- |
Or even better, it is likely a significantly reduced part of the API that is able to return an That is (again) something I've also done that way in the |
Yeah.
Smithay matches on That's the kind of thing that makes |
Based on discussion on Smithay#173. Which this supersedes. All functions in `drm` and `drm_ffi` returning `SystemError`, except `get_planar_frambuffer`, only use it for representing standard Unix error kinds. So `std::io::Error` can be used instead. For `get_planar_framebuffer`, a `GetPlanarFramebufferError` error is defined. It might be nice if Rust has anonymous sum types for this sort of thing, but this seems like the typical pattern. And better than using the same error kind everywhere if `UnrecognizedFourcc` isn't possible in any other function. This should remove `nix` from the public API of the crate. This makes errors a bit simpler to handle for users of the library using `rustix` or a different version of `nix`, and allows `drm` to change which it uses without a breaking API change.
Closing in favor of #173 using |
Based on discussion on Smithay#173. Which this supersedes. All functions in `drm` and `drm_ffi` returning `SystemError`, except `get_planar_frambuffer`, only use it for representing standard Unix error kinds. So `std::io::Error` can be used instead. For `get_planar_framebuffer`, a `GetPlanarFramebufferError` error is defined. It might be nice if Rust has anonymous sum types for this sort of thing, but this seems like the typical pattern. And better than using the same error kind everywhere if `UnrecognizedFourcc` isn't possible in any other function. This should remove `nix` from the public API of the crate. This makes errors a bit simpler to handle for users of the library using `rustix` or a different version of `nix`, and allows `drm` to change which it uses without a breaking API change.
This way users of
drm
can match on constants fromlibc
, or can convert it to the error types from any version ofnix
orrustix
. This addresses a bit of awkwardness in Smithay/smithay#1162 and rust-windowing/softbuffer#164.This should eliminate nix as a "public dependency" of
drm
, though it's still exposed bydrm-ffi
.