pub trait Task:
Send
+ Sync
+ 'static {
type Output: Send + Sync + 'static + Sized;
// 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 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