1 //! windows-specific extension for the `wasmtime` crate. 2 //! 3 //! This module is only available on Windows targets. 4 //! It is not available on Linux or macOS, for example. Note that the import path for 5 //! this module is `wasmtime::windows::...`, which is intended to emphasize that it 6 //! is platform-specific. 7 //! 8 //! The traits contained in this module are intended to extend various types 9 //! throughout the `wasmtime` crate with extra functionality that's only 10 //! available on Windows. 11 12 #[cfg(has_native_signals)] 13 use crate::AsContextMut; 14 use crate::Store; 15 #[cfg(has_native_signals)] 16 use crate::prelude::*; 17 #[cfg(has_native_signals)] 18 use windows_sys::Win32::System::Diagnostics::Debug::EXCEPTION_POINTERS; 19 20 /// Extensions for the [`Store`] type only available on Windows. 21 pub trait StoreExt { 22 /// Configures a custom signal handler to execute. 23 /// 24 /// TODO: needs more documentation. 25 #[cfg(has_native_signals)] set_signal_handler<H>(&mut self, handler: H) where H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync26 unsafe fn set_signal_handler<H>(&mut self, handler: H) 27 where 28 H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync; 29 } 30 31 impl<T> StoreExt for Store<T> { 32 #[cfg(has_native_signals)] set_signal_handler<H>(&mut self, handler: H) where H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync,33 unsafe fn set_signal_handler<H>(&mut self, handler: H) 34 where 35 H: 'static + Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync, 36 { 37 self.as_context_mut() 38 .0 39 .set_signal_handler(Some(Box::new(handler))); 40 } 41 } 42