diff --git a/src/capture.rs b/src/capture.rs index aaf0cf6..7061b66 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -259,10 +259,10 @@ pub trait GraphicsCaptureApiHandler: Sized { Self::new(settings.flags).map_err(GraphicsCaptureApiError::NewHandlerError)?, )); - let item = match settings.item.try_into() { - Ok(item) => item, - Err(_) => return Err(GraphicsCaptureApiError::ItemConvertFailed), - }; + let item = settings + .item + .try_into() + .map_err(|_| GraphicsCaptureApiError::ItemConvertFailed)?; let mut capture = GraphicsCaptureApi::new( item, @@ -332,7 +332,7 @@ pub trait GraphicsCaptureApiHandler: Sized { /// # Returns /// /// Returns `Ok(CaptureControl)` if the capture was successful, otherwise returns an error of type `GraphicsCaptureApiError`. - fn start_free_threaded + Send>( + fn start_free_threaded + Send + 'static>( settings: Settings, ) -> Result, GraphicsCaptureApiError> where @@ -342,11 +342,6 @@ pub trait GraphicsCaptureApiHandler: Sized { let (halt_sender, halt_receiver) = mpsc::channel::>(); let (callback_sender, callback_receiver) = mpsc::channel::>>(); - let item = match settings.item.try_into() { - Ok(item) => item, - Err(_) => return Err(GraphicsCaptureApiError::ItemConvertFailed), - }; - let thread_handle = thread::spawn( move || -> Result<(), GraphicsCaptureApiError> { // Initialize WinRT @@ -376,6 +371,11 @@ pub trait GraphicsCaptureApiHandler: Sized { Self::new(settings.flags).map_err(GraphicsCaptureApiError::NewHandlerError)?, )); + let item = settings + .item + .try_into() + .map_err(|_| GraphicsCaptureApiError::ItemConvertFailed)?; + let mut capture = GraphicsCaptureApi::new( item, callback.clone(),