Skip to main content

main_loop_async/traits/
native.rs

1use std::fmt::Debug;
2/// An async function that is able to be spawned (Not directly able to be
3/// spawned on WASM because of the return type)
4pub trait Spawnable: 'static + Send + std::future::Future<Output: Send + 'static + Debug> {}
5impl<T: 'static + Send + std::future::Future<Output: Send + 'static + Debug>> Spawnable for T {}
6
7/// An async func that accepts a generic argument
8/// and returns a generic value
9pub trait SpawnableWithReturn<Out: Spawnable>: 'static + Send + FnOnce() -> Out {}
10impl<Out: Spawnable, T: 'static + Send + FnOnce() -> Out> SpawnableWithReturn<Out> for T {}
11
12/// An async function that is able to be spawned, lowest common denominator as
13/// we cannot have a return type on WASM
14pub trait SpawnableNoReturn: 'static + Send + std::future::Future<Output = ()> {}
15impl<T: 'static + Send + std::future::Future<Output = ()> + ?Sized> SpawnableNoReturn for T {}