agent_chain_core/outputs/
run_info.rs1use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10#[cfg(feature = "specta")]
11use specta::Type;
12
13#[cfg_attr(feature = "specta", derive(Type))]
22#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
23pub struct RunInfo {
24 pub run_id: Uuid,
26}
27
28impl RunInfo {
29 pub fn new(run_id: Uuid) -> Self {
31 Self { run_id }
32 }
33
34 pub fn new_random() -> Self {
36 Self {
37 run_id: Uuid::new_v4(),
38 }
39 }
40}
41
42impl Default for RunInfo {
43 fn default() -> Self {
44 Self::new_random()
45 }
46}
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_run_info_new() {
54 let id = Uuid::new_v4();
55 let info = RunInfo::new(id);
56 assert_eq!(info.run_id, id);
57 }
58
59 #[test]
60 fn test_run_info_serialization() {
61 let info = RunInfo::new_random();
62 let json = serde_json::to_string(&info).unwrap();
63 let deserialized: RunInfo = serde_json::from_str(&json).unwrap();
64 assert_eq!(deserialized.run_id, info.run_id);
65 }
66}