use rustix::ioctl::{Ioctl, IoctlOutput, Opcode};
use std::ffi::{c_int, c_void};
pub(crate) struct ReturnInt<const OPCODE: Opcode> {}
impl<const OPCODE: Opcode> ReturnInt<OPCODE> {
pub unsafe fn new() -> Self {
Self {}
}
}
unsafe impl<const OPCODE: Opcode> Ioctl for ReturnInt<OPCODE> {
type Output = c_int;
const IS_MUTATING: bool = false;
fn opcode(&self) -> Opcode {
OPCODE
}
fn as_ptr(&mut self) -> *mut c_void {
core::ptr::null_mut()
}
unsafe fn output_from_ptr(out: IoctlOutput, _: *mut c_void) -> rustix::io::Result<Self::Output> {
Ok(out)
}
}
pub(crate) struct IntReturnInt<const OPCODE: Opcode> {
value: usize,
}
impl<const OPCODE: Opcode> IntReturnInt<OPCODE> {
pub unsafe fn new(value: usize) -> Self {
Self { value }
}
}
unsafe impl<const OPCODE: Opcode> Ioctl for IntReturnInt<OPCODE> {
type Output = c_int;
const IS_MUTATING: bool = false;
fn opcode(&self) -> Opcode {
OPCODE
}
fn as_ptr(&mut self) -> *mut c_void {
self.value as *mut c_void
}
unsafe fn output_from_ptr(out: IoctlOutput, _: *mut c_void) -> rustix::io::Result<Self::Output> {
Ok(out)
}
}