use std::{
num::NonZeroI32,
os::{fd, fd::AsRawFd as _},
};
use dope_sys::engine::register;
pub(super) struct Descriptor(NonZeroI32, register::Interest);
impl Descriptor {
pub(super) unsafe fn new(source: register::Source<'_>) -> Self {
Self(
unsafe { NonZeroI32::new_unchecked(!source.fd.as_raw_fd()) },
source.interest,
)
}
pub(super) fn source(&self) -> register::Source<'_> {
register::Source {
fd: unsafe { fd::BorrowedFd::borrow_raw(!self.0.get()) },
interest: self.1,
}
}
}