1use std::collections::HashMap;
4use chrono::{DateTime, Utc};
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ExecutionContext {
10 variables: HashMap<String, String>,
12
13 timestamp: DateTime<Utc>,
15
16 metadata: HashMap<String, String>,
18}
19
20impl ExecutionContext {
21 pub fn new() -> Self {
23 Self {
24 variables: HashMap::new(),
25 timestamp: Utc::now(),
26 metadata: HashMap::new(),
27 }
28 }
29
30 pub fn set_variable(&mut self, key: String, value: String) {
32 self.variables.insert(key, value);
33 }
34
35 pub fn get_variable(&self, key: &str) -> Option<&String> {
37 self.variables.get(key)
38 }
39
40 pub fn get_variables(&self) -> &HashMap<String, String> {
42 &self.variables
43 }
44
45 pub fn timestamp(&self) -> DateTime<Utc> {
47 self.timestamp
48 }
49
50 pub fn set_metadata(&mut self, key: String, value: String) {
52 self.metadata.insert(key, value);
53 }
54
55 pub fn get_metadata(&self, key: &str) -> Option<&String> {
57 self.metadata.get(key)
58 }
59}
60
61impl Default for ExecutionContext {
62 fn default() -> Self {
63 Self::new()
64 }
65}