TaskStatusInfo

Trait TaskStatusInfo 

Source
pub trait TaskStatusInfo {
    // Required methods
    fn get_task_state(&self) -> TaskState;
    fn get_process_state(&self) -> ProcessState;
    fn get_process_id(&self) -> Option<u32>;
    fn get_create_at(&self) -> SystemTime;
    fn get_running_at(&self) -> Option<SystemTime>;
    fn get_finished_at(&self) -> Option<SystemTime>;
    fn get_exit_code(&self) -> Option<i32>;
    fn get_last_signal_code(&self) -> Option<Signal>;

    // Provided method
    fn get_information(&self) -> TaskInformation { ... }
}
Expand description

Trait for retrieving task status information.

This trait provides methods to query the current state and runtime information of a task.

Required Methods§

Source

fn get_task_state(&self) -> TaskState

Gets the current state of the task.

§Returns

The current TaskState of the task

Source

fn get_process_state(&self) -> ProcessState

Gets the current state of the process.

§Returns

The current ProcessState of the process

Source

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

Gets the process ID of the running task.

§Returns
  • Some(u32) - The process ID if the task is running
  • None - If process hasn’t started yet or has finished
Source

fn get_create_at(&self) -> SystemTime

Gets the creation timestamp of the task.

§Returns

The SystemTime when the task was created

Source

fn get_running_at(&self) -> Option<SystemTime>

Gets the timestamp when the task started running.

§Returns
  • Some(SystemTime) - When the task started running
  • None - If the task hasn’t started yet
Source

fn get_finished_at(&self) -> Option<SystemTime>

Gets the timestamp when the task finished.

§Returns
  • Some(SystemTime) - When the task finished
  • None - If the task is still running or hasn’t started
Source

fn get_exit_code(&self) -> Option<i32>

Gets the exit code of the finished task.

§Returns
  • Some(i32) - The exit code if the task has finished
  • None - If the task is still running or hasn’t started
Source

fn get_last_signal_code(&self) -> Option<Signal>

Gets the last received signal (if any) from the process.

§Returns
  • Some(i32) - The last signal number if available
  • None - If no signal has been received or not applicable

Provided Methods§

Source

fn get_information(&self) -> TaskInformation

Gets all information about the task.

This is a convenience method that collects all status information into a single structure.

§Returns

A TaskInformation struct containing all task status data

§Example
use tcrm_task::tasks::control::TaskStatusInfo;
use tcrm_task::tasks::config::TaskConfig;
use tcrm_task::tasks::tokio::executor::TaskExecutor;
use tokio::sync::mpsc;

let config = TaskConfig::new("echo".to_string());
let (tx, _rx) = mpsc::channel(100);
let task = TaskExecutor::new(config, tx);
let info = task.get_information();
println!("Task state: {:?}", info.task_state);
if let Some(pid) = info.process_id {
    println!("Process ID: {}", pid);
}

Implementors§