taskflow_rs/task/
result.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct TaskResult {
6    pub success: bool,
7    pub output: Option<String>,
8    pub error: Option<String>,
9    pub execution_time_ms: u64,
10    pub metadata: HashMap<String, String>,
11}
12
13impl TaskResult {
14    pub fn success(output: impl Into<String>, execution_time_ms: u64) -> Self {
15        Self {
16            success: true,
17            output: Some(output.into()),
18            error: None,
19            execution_time_ms,
20            metadata: HashMap::new(),
21        }
22    }
23
24    pub fn failure(error: impl Into<String>, execution_time_ms: u64) -> Self {
25        Self {
26            success: false,
27            output: None,
28            error: Some(error.into()),
29            execution_time_ms,
30            metadata: HashMap::new(),
31        }
32    }
33}