diff --git a/lib/wasi/src/runners/mod.rs b/lib/wasi/src/runners/mod.rs index ae12493aab6..3aca293256e 100644 --- a/lib/wasi/src/runners/mod.rs +++ b/lib/wasi/src/runners/mod.rs @@ -14,7 +14,7 @@ pub use self::runner::Runner; use anyhow::Error; use wasmer::{Engine, Module}; -pub type CompileModule = dyn Fn(&Engine, &[u8]) -> Result; +pub type CompileModule = dyn Fn(&Engine, &[u8]) -> Result + Send + Sync; #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct MappedDirectory { diff --git a/lib/wasi/src/runners/wasi.rs b/lib/wasi/src/runners/wasi.rs index 59f65231bf9..0c4d08f70d4 100644 --- a/lib/wasi/src/runners/wasi.rs +++ b/lib/wasi/src/runners/wasi.rs @@ -41,7 +41,7 @@ impl WasiRunner { /// Sets the compile function pub fn with_compile( mut self, - compile: impl Fn(&Engine, &[u8]) -> Result + 'static, + compile: impl Fn(&Engine, &[u8]) -> Result + Send + Sync + 'static, ) -> Self { self.compile = Some(Box::new(compile)); self @@ -190,3 +190,17 @@ impl crate::runners::Runner for WasiRunner { Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn send_and_sync() { + fn assert_send() {} + fn assert_sync() {} + + assert_send::(); + assert_sync::(); + } +} diff --git a/lib/wasi/src/runners/wcgi/runner.rs b/lib/wasi/src/runners/wcgi/runner.rs index beb3a25b9b6..b75c733946b 100644 --- a/lib/wasi/src/runners/wcgi/runner.rs +++ b/lib/wasi/src/runners/wcgi/runner.rs @@ -120,7 +120,7 @@ impl WcgiRunner { /// Sets the compile function pub fn with_compile( mut self, - compile: impl Fn(&Engine, &[u8]) -> Result + 'static, + compile: impl Fn(&Engine, &[u8]) -> Result + Send + Sync + 'static, ) -> Self { self.compile = Some(Arc::new(compile)); self @@ -374,3 +374,17 @@ pub trait Callbacks: Send + Sync + 'static { struct NoopCallbacks; impl Callbacks for NoopCallbacks {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn send_and_sync() { + fn assert_send() {} + fn assert_sync() {} + + assert_send::(); + assert_sync::(); + } +}