1use std::os::fd;
2
3use dope_sys::io::{
4 file,
5 reactor::complete::{Decode, Outcome as _},
6};
7
8use crate::{
9 Uring,
10 reactor::cq::{Invalid, Outcome},
11};
12
13unsafe impl file::raw::Completion for Uring {
16 type Outcome = Outcome;
17 type Invalid = Invalid;
18
19 unsafe fn open(raw: Self::Outcome) -> Result<file::Opened, Self::Invalid> {
20 match raw.decode() {
21 Decode::Value(value) => {
22 let owned =
24 unsafe { <fd::OwnedFd as fd::FromRawFd>::from_raw_fd(value.get() as i32) };
25 Ok(Ok(owned))
26 }
27 Decode::Error(code) => Ok(Err(code)),
28 Decode::Invalid(invalid) => Err(invalid),
29 }
30 }
31}