1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::runtime::{
    job::task::{log_monitor::LogMonitor, process::Process},
    local_bin::BinCommand,
};
use std::collections::HashMap;

/// Runtime context object.
///
/// This object contains indexes to defined processes and log monitors as well as the current
/// `BinCommand` object.
#[derive(Clone, Debug)]
pub struct Ctx {
    pub bin_command: BinCommand,
    pub log_monitor_map: HashMap<String, LogMonitor>,
    pub process_map: HashMap<String, Process>,
}

impl Default for Ctx {
    fn default() -> Self {
        Self::new()
    }
}

impl Ctx {
    /// Constructs a new, empty `Ctx`.
    pub fn new() -> Self {
        Self {
            bin_command: BinCommand::system_default(),
            log_monitor_map: HashMap::new(),
            process_map: HashMap::new(),
        }
    }
}