use crate::{error, UsbContext};
use libusb1_sys::{constants::*, libusb_set_option};
pub struct UsbOption {
inner: OptionInner,
}
impl UsbOption {
#[cfg(windows)]
pub fn use_usbdk() -> Self {
Self {
inner: OptionInner::UseUsbdk,
}
}
pub(crate) fn apply<T: UsbContext>(&self, ctx: &mut T) -> crate::Result<()> {
match self.inner {
OptionInner::UseUsbdk => {
let err = unsafe { libusb_set_option(ctx.as_raw(), LIBUSB_OPTION_USE_USBDK) };
if err == LIBUSB_SUCCESS {
Ok(())
} else {
Err(error::from_libusb(err))
}
}
}
}
}
enum OptionInner {
#[cfg_attr(not(windows), allow(dead_code))] UseUsbdk,
}