io-uring icon indicating copy to clipboard operation
io-uring copied to clipboard

Convert negative CQE results to io::Error

Open asayers opened this issue 2 weeks ago • 3 comments

The following text is found in many io_uring man pages:

Note that where synchronous system calls will return -1 on failure
and set errno to the actual error value, io_uring never uses errno.
Instead it returns the negated errno directly in the CQE res field.

My understanding is that a negative value in the res field is always a negated errno. Converting negative values to io::Error removes a footgun, and is often more convenient. You can recover the original errno with Error::raw_os_error().

(This is a backport of https://github.com/jordanisaacs/rustix-uring/pull/11 and https://github.com/jordanisaacs/rustix-uring/pull/15)

asayers avatar Dec 15 '25 06:12 asayers

I don't reject this, but it would be a break change. would you can to add another method that returns io::Result? like io_result(self) -> io::Result<u32>

quininer avatar Dec 15 '25 07:12 quininer

Yes, that's probably a good idea. io_result() works; but I wonder if there's something shorter we could use?

asayers avatar Dec 15 '25 12:12 asayers

Of course, you can consider a better name.

quininer avatar Dec 15 '25 13:12 quininer