diff --git a/src/app.rs b/src/app.rs index e346bb3..3c3cfff 100644 --- a/src/app.rs +++ b/src/app.rs @@ -47,7 +47,7 @@ impl App { pub fn run(self) -> Result<()> { display_control::log_current_source(); - let pnp_detector = PnPDetect::new(&self); + let pnp_detector = PnPDetect::new(Box::new(self)); pnp_detector.detect()?; Ok(()) diff --git a/src/platform/pnp_detect_windows.rs b/src/platform/pnp_detect_windows.rs index 32dca93..baad0eb 100644 --- a/src/platform/pnp_detect_windows.rs +++ b/src/platform/pnp_detect_windows.rs @@ -22,14 +22,14 @@ use winapi::um::winuser::{ /// Detection of plugged in / removed USB devices on Windows: listens for WM_DEVICECHANGE messages. /// This code should be removed once libusb supports hotplug notifications on Windows: /// https://github.com/libusb/libusb/issues/86 -pub struct PnPDetectWindows<'a> { +pub struct PnPDetectWindows { hwnd: HWND, - callback: &'a dyn UsbCallback, + callback: Box, current_devices: HashSet, } -impl<'a> PnPDetectWindows<'a> { - pub fn new(callback: &'a (dyn UsbCallback + 'a)) -> Self { +impl PnPDetectWindows { + pub fn new(callback: Box) -> Self { let mut pnp_detect = Self { callback, current_devices: Self::read_device_list().unwrap_or_default(),