1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
//! Unix-specific extension for the `wasmtime` crate. //! //! This module is only available on Unix targets, for example Linux. Note that //! this module is notably not available on macOS or Windows. Note that the //! import path for this module is `wasmtime::unix::...`, which is intended to //! emphasize that it is platform-specific. //! //! The traits contained in this module are intended to extend various types //! throughout the `wasmtime` crate with extra functionality that's only //! available on Unix. use crate::{AsContextMut, Store}; /// Extensions for the [`Store`] type only available on Unix. pub trait StoreExt { // TODO: needs more docs? /// The signal handler must be /// [async-signal-safe](http://man7.org/linux/man-pages/man7/signal-safety.7.html). unsafe fn set_signal_handler<H>(&mut self, handler: H) where H: 'static + Fn(libc::c_int, *const libc::siginfo_t, *const libc::c_void) -> bool + Send + Sync; } impl<T> StoreExt for Store<T> { unsafe fn set_signal_handler<H>(&mut self, handler: H) where H: 'static + Fn(libc::c_int, *const libc::siginfo_t, *const libc::c_void) -> bool + Send + Sync, { self.as_context_mut() .opaque() .set_signal_handler(Some(Box::new(handler))); } }