monitor/src/options/structs.rs

84 lines
2.4 KiB
Rust

use serde::{Deserialize, Serialize};
/// # an Error enum (next will be deleted and replaced)
pub enum CustomError {
Fatal,
}
#[derive(Debug, PartialEq)]
pub enum ConfigActuality {
Local,
Remote,
}
/// # struct for the 1st level in json conf file
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Processes {
// #[serde(rename="id")]
// runner_id: usize,
#[serde(rename = "dateOfCreation")]
pub date_of_creation: String,
#[serde(rename = "configServer")]
pub config_server: String,
#[serde(default)]
pub processes: Vec<TrackingProcess>,
}
/// # struct for each process to contain info, such as name, path and dependencies
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TrackingProcess {
pub name: String,
pub path: String,
pub dependencies: Dependencies,
}
/// # struct for processes' dependencies including files and services
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Dependencies {
#[serde(default)]
pub files: Vec<Files>,
#[serde(default)]
pub services: Vec<Services>,
}
/// # struct for containing file object with its triggers to manipulate in daemons
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Files {
pub filename: String,
pub src: String,
pub triggers: FIleTriggers,
}
/// # struct for containing service object with its triggers to manipulate in daemons
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Services {
pub hostname: String,
pub port: u32,
pub triggers: ServiceTriggers,
}
/// # struct for instancing each service's policies such as on lost or time to wait till reachable
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ServiceTriggers {
pub wait: u32,
pub delay: u32,
#[serde(rename = "onLost")]
pub on_lost: String,
}
/// # struct for instancing each file's policies such as on-delete or onupdate events
/// > (needed in serialization and deserialization)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FIleTriggers {
#[serde(rename = "onDelete")]
pub on_delete: String,
#[serde(rename = "onChange")]
pub on_change: String,
}