diff --git a/interpreter/src/context.rs b/interpreter/src/context.rs index b86c5af..0b21f67 100644 --- a/interpreter/src/context.rs +++ b/interpreter/src/context.rs @@ -117,7 +117,7 @@ impl<'a> Context<'a> { pub fn add_function(&mut self, name: &str, value: F) where - F: Handler + 'static, + F: Handler + 'static + Send + Sync, { if let Context::Root { functions, .. } = self { functions.add(name, value); diff --git a/interpreter/src/magic.rs b/interpreter/src/magic.rs index ec79cc2..605876a 100644 --- a/interpreter/src/magic.rs +++ b/interpreter/src/magic.rs @@ -302,7 +302,7 @@ pub struct FunctionRegistry { impl FunctionRegistry { pub(crate) fn add(&mut self, name: &str, handler: H) where - H: Handler + 'static, + H: Handler + 'static + Send + Sync, T: 'static, { self.functions.insert( @@ -323,18 +323,18 @@ impl FunctionRegistry { } } -pub trait Function { +pub trait Function: Send + Sync { fn clone_box(&self) -> Box; fn into_callable<'a>(self: Box, ctx: &'a mut FunctionContext) -> Box; fn call_with_context(self: Box, ctx: &mut FunctionContext) -> ResolveResult; } -pub struct HandlerFunction { +pub struct HandlerFunction { pub handler: H, pub into_callable: for<'a> fn(H, &'a mut FunctionContext) -> Box, } -impl Clone for HandlerFunction { +impl Clone for HandlerFunction { fn clone(&self) -> Self { Self { handler: self.handler.clone(), @@ -345,7 +345,7 @@ impl Clone for HandlerFunction { impl Function for HandlerFunction where - H: Clone + 'static, + H: Clone + Send + Sync + 'static, { fn clone_box(&self) -> Box { Box::new(self.clone())