TaskMonitorEvent

Enum TaskMonitorEvent 

Source
pub enum TaskMonitorEvent {
    Task(TaskEvent),
    Started {
        total_tasks: usize,
    },
    Completed {
        completed_tasks: usize,
        failed_tasks: usize,
    },
    Control(TaskMonitorControlEvent),
    Error(TaskMonitorError),
}
Expand description

Events emitted by TaskMonitor during execution.

These events provide real-time information about task execution progress, control message processing, and error conditions. They can be used to build user interfaces, logging systems, or progress monitoring.

§Event Categories

  • Task Events: Forwarded from individual tasks (started, output, stopped, etc.)
  • Execution Events: Monitor-level events (started, completed)
  • Control Events: Events related to runtime control (stop, stdin, terminate)
  • Error Events: Error conditions during monitoring

§Examples

§Basic Event Monitoring

use tokio::sync::mpsc;
use tcrm_monitor::monitor::event::TaskMonitorEvent;

let (event_tx, mut event_rx) = mpsc::channel(100);

// Spawn a task to handle events
tokio::spawn(async move {
    while let Some(event) = event_rx.recv().await {
        match event {
            TaskMonitorEvent::Started { total_tasks } => {
                println!("Starting execution of {} tasks", total_tasks);
            }
            TaskMonitorEvent::Task(task_event) => {
                println!("Task event: {:?}", task_event);
            }
            TaskMonitorEvent::Completed { completed_tasks, failed_tasks } => {
                println!("Execution complete: {} completed, {} failed",
                         completed_tasks, failed_tasks);
                break;
            }
            _ => {}
        }
    }
});

Variants§

§

Task(TaskEvent)

A task event from the underlying task system.

This forwards events from individual tasks, including:

  • Task started
  • Task output (stdout/stderr)
  • Task ready state changes
  • Task stopped/completed
  • Task errors

§Examples

use tcrm_monitor::monitor::event::TaskMonitorEvent;
use tcrm_task::tasks::event::TaskEvent;

let event = TaskMonitorEvent::Task(TaskEvent::Started {
    task_name: "build".to_string()
});
§

Started

Monitor execution started.

Emitted when task execution begins, providing the total number of tasks to execute.

§Fields

  • total_tasks - Total number of tasks in the execution plan

§Examples

use tcrm_monitor::monitor::event::TaskMonitorEvent;

let event = TaskMonitorEvent::Started { total_tasks: 5 };

Fields

§total_tasks: usize

Total number of tasks to execute

§

Completed

Monitor execution completed.

Emitted when all tasks have finished (either successfully or with errors).

§Fields

  • completed_tasks - Number of tasks that completed successfully
  • failed_tasks - Number of tasks that failed or were terminated

§Examples

use tcrm_monitor::monitor::event::TaskMonitorEvent;

let event = TaskMonitorEvent::Completed {
    completed_tasks: 3,
    failed_tasks: 1
};

Fields

§completed_tasks: usize

Number of tasks completed successfully

§failed_tasks: usize

Number of tasks that failed

§

Control(TaskMonitorControlEvent)

§

Error(TaskMonitorError)

Trait Implementations§

Source§

impl Clone for TaskMonitorEvent

Source§

fn clone(&self) -> TaskMonitorEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskMonitorEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.