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 };
Completed
Monitor execution completed.
Emitted when all tasks have finished (either successfully or with errors).
§Fields
completed_tasks
- Number of tasks that completed successfullyfailed_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
Control(TaskMonitorControlEvent)
Error(TaskMonitorError)
Trait Implementations§
Source§impl Clone for TaskMonitorEvent
impl Clone for TaskMonitorEvent
Source§fn clone(&self) -> TaskMonitorEvent
fn clone(&self) -> TaskMonitorEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for TaskMonitorEvent
impl RefUnwindSafe for TaskMonitorEvent
impl Send for TaskMonitorEvent
impl Sync for TaskMonitorEvent
impl Unpin for TaskMonitorEvent
impl UnwindSafe for TaskMonitorEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more