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§
Sourcefn get_task_state(&self) -> TaskState
fn get_task_state(&self) -> TaskState
Sourcefn get_process_state(&self) -> ProcessState
fn get_process_state(&self) -> ProcessState
Sourcefn get_process_id(&self) -> Option<u32>
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 runningNone- If process hasn’t started yet or has finished
Sourcefn get_create_at(&self) -> SystemTime
fn get_create_at(&self) -> SystemTime
Sourcefn get_running_at(&self) -> Option<SystemTime>
fn get_running_at(&self) -> Option<SystemTime>
Gets the timestamp when the task started running.
§Returns
Some(SystemTime)- When the task started runningNone- If the task hasn’t started yet
Sourcefn get_finished_at(&self) -> Option<SystemTime>
fn get_finished_at(&self) -> Option<SystemTime>
Gets the timestamp when the task finished.
§Returns
Some(SystemTime)- When the task finishedNone- If the task is still running or hasn’t started
Sourcefn get_exit_code(&self) -> Option<i32>
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 finishedNone- If the task is still running or hasn’t started
Sourcefn get_last_signal_code(&self) -> Option<Signal>
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 availableNone- If no signal has been received or not applicable
Provided Methods§
Sourcefn get_information(&self) -> TaskInformation
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);
}