From 74bebe6da37c6315b509aa212fdf03fabcb70058 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 26 Aug 2024 11:13:06 +0100 Subject: [PATCH] Add optional `Send` requirement to internall callbacks --- src/types.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 8357c12..39ff12a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -46,6 +46,10 @@ unsafe impl Send for LightUserData {} #[cfg(feature = "send")] unsafe impl Sync for LightUserData {} +#[cfg(feature = "send")] +pub(crate) type Callback = Box Result + Send + 'static>; + +#[cfg(not(feature = "send"))] pub(crate) type Callback = Box Result + 'static>; pub(crate) struct Upvalue { @@ -55,7 +59,11 @@ pub(crate) struct Upvalue { pub(crate) type CallbackUpvalue = Upvalue; -#[cfg(feature = "async")] +#[cfg(all(feature = "async", feature = "send"))] +pub(crate) type AsyncCallback = + Box Fn(&'a RawLua, c_int) -> BoxFuture<'a, Result> + Send + 'static>; + +#[cfg(all(feature = "async", not(feature = "send")))] pub(crate) type AsyncCallback = Box Fn(&'a RawLua, c_int) -> BoxFuture<'a, Result> + 'static>;