Use std::io::Error
for error results, except get_planar_framebuffer
#179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on discussion on #173. Which this supersedes.
All functions in
drm
anddrm_ffi
returningSystemError
, exceptget_planar_frambuffer
, only use it for representing standard Unix error kinds. Sostd::io::Error
can be used instead.For
get_planar_framebuffer
, aGetPlanarFramebufferError
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 ifUnrecognizedFourcc
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 usingrustix
or a different version ofnix
, and allowsdrm
to change which it uses without a breaking API change.Testing this in Smithay (Smithay/smithay@master...ids1024:smithay:drm-rs-update), the section where it was matching on several variants of
SystemError
is simplified, and other things aren't changed much. Usingio::Error
in a variant did however mean removingClone
andCopy
fromdrm_lease::Error
. But those shouldn't really be needed for an error kind generally.(Softbuffer is also trivial to update.
cosmic-comp
required no changes with the patched Smithay above. I'm not familiar with other users of drm-rs.)In some ways the
Errno
types fromnix
orrustix
would be better, but it's best not to have a public dependency on that or duplicate it.