pub use abi::io::{device::*, MountOptions, UnmountOptions};

use abi::{error::Error, io::RawFd, option::RequestValue};

pub fn device_request<'de, T: RequestValue<'de>>(
    fd: RawFd,
    buffer: &'de mut [u8],
    request: &T::Request,
) -> Result<T::Response, Error> {
    let len = T::store_request(request, buffer)?;
    let len = unsafe { crate::sys::device_request(fd, T::VARIANT.into(), buffer, len) }?;
    T::load_response(&buffer[..len])
}
