use actix::Message; use std::{ collections::HashMap, ops::{Deref, DerefMut}, }; #[derive(Clone, Message)] #[rtype(result = "()")] pub struct Jobs(Vec); impl Jobs { pub fn new(tasks: Vec) -> Self { Self(tasks) } } impl std::fmt::Debug for Jobs { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Jobs") .field( "list", &self.iter().map(|j| j.name.clone()).collect::>(), ) .finish() } } impl Deref for Jobs { type Target = Vec; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Jobs { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } #[derive(Clone, Debug, Message)] #[rtype(result = "()")] pub struct Job { pub name: String, pub command: String, pub path: String, pub env: HashMap, pub retry: bool, pub keep_alive: bool, pub retry_delay: u64, } impl Default for Job { fn default() -> Self { Job { name: "Unnamed".to_string(), command: "".to_string(), path: ".".to_string(), env: HashMap::new(), retry: true, keep_alive: true, retry_delay: 2, } } }