Trait send_sync_static::FutureSSS
source · pub trait FutureSSS: Future + SSS { }
Expand description
A marker which identifies a Future
(but not necessarily its output) as Send
, Sync
, and 'static
.
This trait is automatically implemented for futures which fulfill these requirements, and it is intended to be used as a shorthand for writing out each bound. For example:
use send_sync_static::{FutureSSS, SSS};
pub fn send_data<D: SSS>(data: D) -> impl FutureSSS {
// Guarantees the async block is always Send, Sync, and 'static
async move {
// Do something here
drop(data)
}
}
This can be combined with RPITIT, an upcoming stable feature.
ⓘ
use send_sync_static::FutureSSS;
pub trait Database {
fn add_user(&self, user: String) -> impl FutureSSS<Output = ()>;
}
Code written explicitly using Send
, Sync
, and 'static
is fully interchangeable with this trait.