Skip to content

Commit

Permalink
feat: remove send bounds in WASM for all traits
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jan 5, 2025
1 parent dda1232 commit 341f7fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,3 @@ mod wasm;
pub use native::*;
#[cfg(target_arch = "wasm32")]
pub use wasm::*;

/// A function able to be used as a Call Back to notify the UI that the request
/// is ready
pub trait UiCallBack: 'static + Send + FnOnce() {}
impl<T> UiCallBack for T where T: 'static + Send + FnOnce() {}

/// Allowed return types
pub trait ValidReturn: Send + 'static {}
impl<T: Send + 'static> ValidReturn for T {}
9 changes: 9 additions & 0 deletions src/traits/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ impl<T, O: BoundedFuture<()>> DoneHandler<O> for T where
/// A future with the required bounds for the platform
pub trait BoundedFuture<O>: Future<Output = O> + Send {}
impl<T, O> BoundedFuture<O> for T where T: Future<Output = O> + Send {}

/// A function able to be used as a Call Back to notify the UI that the request
/// is ready
pub trait UiCallBack: 'static + Send + FnOnce() {}
impl<T> UiCallBack for T where T: 'static + Send + FnOnce() {}

/// Allowed return types
pub trait ValidReturn: Send + 'static {}
impl<T: Send + 'static> ValidReturn for T {}
8 changes: 8 additions & 0 deletions src/traits/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ impl<T, O: BoundedFuture<()>> DoneHandler<O> for T where
T: 'static + FnOnce(reqwest::Result<reqwest::Response>) -> O
{
}

/// dox
pub trait UiCallBack: 'static + FnOnce() {}
impl<T> UiCallBack for T where T: 'static + FnOnce() {}

/// dox
pub trait ValidReturn: 'static {}
impl<T: 'static> ValidReturn for T {}

0 comments on commit 341f7fb

Please sign in to comment.