clementine_core::task

Trait Task

Source
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§

Source

const VARIANT: TaskVariant

The variant of the task

Required Associated Types§

Source

type Output: Send + Sync + 'static + Sized

The output of the fn run_once

Required Methods§

Source

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 immediately
  • Ok(false) if the task did not do work and should wait before running again
  • Err(...) 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.

Implementors§

Source§

impl Task for BitcoinSyncerTask

Source§

const VARIANT: TaskVariant = TaskVariant::BitcoinSyncer

Source§

type Output = bool

Source§

impl Task for TxSenderTask

Source§

const VARIANT: TaskVariant = TaskVariant::TxSender

Source§

type Output = bool

Source§

impl Task for AggregatorMetricPublisher

Source§

const VARIANT: TaskVariant = TaskVariant::MetricPublisher

Source§

type Output = bool

Source§

impl Task for TaskStatusMonitorTask

Source§

const VARIANT: TaskVariant = TaskVariant::TaskStatusMonitor

Source§

type Output = bool

Source§

impl<C> Task for PayoutCheckerTask<C>
where C: CitreaClientT,

Source§

const VARIANT: TaskVariant = TaskVariant::PayoutChecker

Source§

type Output = bool

Source§

impl<H: BlockHandler> Task for FinalizedBlockFetcherTask<H>

Source§

const VARIANT: TaskVariant = TaskVariant::FinalizedBlockFetcher

Source§

type Output = bool

Source§

impl<T: Owner + Debug + 'static> Task for MessageConsumerTask<T>

Source§

const VARIANT: TaskVariant = TaskVariant::StateManager

Source§

type Output = bool

Source§

impl<T: NamedEntity> Task for EntityMetricPublisher<T>

Source§

const VARIANT: TaskVariant = TaskVariant::MetricPublisher

Source§

type Output = bool

Source§

impl<T: Task + Sized + Debug> Task for BufferedErrors<T>
where T::Output: Default,

Source§

const VARIANT: TaskVariant = T::VARIANT

Source§

type Output = <T as Task>::Output

Source§

impl<T: Task + Sized + Debug> Task for IgnoreError<T>
where T::Output: Default,

Source§

const VARIANT: TaskVariant = T::VARIANT

Source§

type Output = <T as Task>::Output

Source§

impl<T: Task + Sized> Task for CancelableLoop<T>

Source§

const VARIANT: TaskVariant = T::VARIANT

Source§

type Output = ()

Source§

impl<T: Task + Sized, F: Fn(T::Output) -> T::Output + Send + Sync + 'static> Task for Map<T, F>

Source§

const VARIANT: TaskVariant = T::VARIANT

Source§

type Output = <T as Task>::Output

Source§

impl<T: Task> Task for CancelableTask<T>

Source§

impl<T: Task> Task for WithDelay<T>
where T::Output: Into<bool>,