use std::collections::HashMap;
use std::time::Duration;
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub struct Execution {
pub expression: String,
pub environment: Option<HashMap<String, String>>,
pub timeout: Option<Duration>,
}
impl Execution {
pub fn new(expression: &str) -> Self {
Execution {
expression: expression.to_string(),
..Default::default()
}
}
pub fn expression(mut self, expression: &str) -> Self {
self.expression = expression.into();
self
}
pub fn environment(mut self, keys_values: &[(&str, &str)]) -> Self {
self.environment = Some(HashMap::from_iter(
keys_values
.iter()
.map(|(k, v)| (k.to_string(), v.to_string())),
));
self
}
pub fn timeout(mut self, timeout: Option<Duration>) -> Self {
self.timeout = timeout;
self
}
}