use std::collections::HashMap;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionContext {
variables: HashMap<String, String>,
timestamp: DateTime<Utc>,
metadata: HashMap<String, String>,
}
impl ExecutionContext {
pub fn new() -> Self {
Self {
variables: HashMap::new(),
timestamp: Utc::now(),
metadata: HashMap::new(),
}
}
pub fn set_variable(&mut self, key: String, value: String) {
self.variables.insert(key, value);
}
pub fn get_variable(&self, key: &str) -> Option<&String> {
self.variables.get(key)
}
pub fn get_variables(&self) -> &HashMap<String, String> {
&self.variables
}
pub fn timestamp(&self) -> DateTime<Utc> {
self.timestamp
}
pub fn set_metadata(&mut self, key: String, value: String) {
self.metadata.insert(key, value);
}
pub fn get_metadata(&self, key: &str) -> Option<&String> {
self.metadata.get(key)
}
}
impl Default for ExecutionContext {
fn default() -> Self {
Self::new()
}
}