Skip to main content

ExecutableItem

Trait ExecutableItem 

Source
pub trait ExecutableItem: Send + 'static {
    // Required method
    fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult;

    // Provided methods
    fn declare_triggers(
        &mut self,
        d: &mut TriggerDeclarer<'_>,
    ) -> Result<(), ExecutorError> { ... }
    fn task_id(&self) -> Option<&str> { ... }
    fn app_id(&self) -> Option<u32> { ... }
    fn app_instance_id(&self) -> Option<u32> { ... }
}
Expand description

Trait implemented by every unit of work the executor schedules.

Implementors are moved into the executor and dispatched to pool workers. Send + 'static is required; Sync is not — the executor guarantees at most one thread at a time invokes execute on a given item.

Required Methods§

Source

fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult

Called by the executor when any declared trigger fires.

Provided Methods§

Source

fn declare_triggers( &mut self, d: &mut TriggerDeclarer<'_>, ) -> Result<(), ExecutorError>

Called once when the item is added to an executor. The implementor registers its trigger handles via the TriggerDeclarer.

Source

fn task_id(&self) -> Option<&str>

Optional human-readable id used for monitor/observer correlation. None means “use the auto-assigned id”.

Source

fn app_id(&self) -> Option<u32>

Optional application id; Some(_) enables Observer per-app callbacks.

Source

fn app_instance_id(&self) -> Option<u32>

Optional application instance id.

Trait Implementations§

Source§

impl ExecutableItem for Box<dyn ExecutableItem>

Allows Vec<Box<dyn ExecutableItem>> to be passed directly to crate::Executor::add_chain without a secondary wrapper.

Source§

fn declare_triggers( &mut self, d: &mut TriggerDeclarer<'_>, ) -> Result<(), ExecutorError>

Called once when the item is added to an executor. The implementor registers its trigger handles via the TriggerDeclarer.
Source§

fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult

Called by the executor when any declared trigger fires.
Source§

fn task_id(&self) -> Option<&str>

Optional human-readable id used for monitor/observer correlation. None means “use the auto-assigned id”.
Source§

fn app_id(&self) -> Option<u32>

Optional application id; Some(_) enables Observer per-app callbacks.
Source§

fn app_instance_id(&self) -> Option<u32>

Optional application instance id.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ExecutableItem for Box<dyn ExecutableItem>

Allows Vec<Box<dyn ExecutableItem>> to be passed directly to crate::Executor::add_chain without a secondary wrapper.

Source§

fn declare_triggers( &mut self, d: &mut TriggerDeclarer<'_>, ) -> Result<(), ExecutorError>

Source§

fn execute(&mut self, ctx: &mut Context<'_>) -> ExecuteResult

Source§

fn task_id(&self) -> Option<&str>

Source§

fn app_id(&self) -> Option<u32>

Source§

fn app_instance_id(&self) -> Option<u32>

Implementors§

Source§

impl<D, E> ExecutableItem for FnItemWithTriggers<D, E>
where D: FnOnce(&mut TriggerDeclarer<'_>) -> Result<(), ExecutorError> + Send + 'static, E: FnMut(&mut Context<'_>) -> ExecuteResult + Send + 'static,

Source§

impl<F> ExecutableItem for FnItem<F>
where F: FnMut(&mut Context<'_>) -> ExecuteResult + Send + 'static,

Source§

impl<I, F> ExecutableItem for Conditional<I, F>
where I: ExecutableItem, F: FnMut() -> bool + Send + 'static,

Source§

impl<T: Payload + Copy + Send> ExecutableItem for SlotItem<T>

Source§

impl<T: Payload + Default + Copy + Send> ExecutableItem for SignalItem<T>