pub trait Task:
Send
+ Sync
+ 'static {
type Output: Send + Sync + 'static + Sized;
const VARIANT: TaskVariant;
// Required method
fn run_once<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Task trait defining the core behavior for cancelable background tasks
This trait is implemented by any struct that needs to run as a background task. The run_once method contains the main logic of the task, and returns a bool indicating whether it did work (true) or needs to wait (false).
Required Associated Constants§
Sourceconst VARIANT: TaskVariant
const VARIANT: TaskVariant
The variant of the task
Required Associated Types§
Required Methods§
Sourcefn run_once<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, BridgeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_once<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, BridgeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the task once, returning whether work was done
Returns:
Ok(true)
if the task did some work and is ready to run again immediatelyOk(false)
if the task did not do work and should wait before running againErr(...)
if the task encountered an error
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.