scsys_agents/core/contexts/
context.rs

1/*
2    Appellation: context <module>
3    Contributors: FL03 <jo3mccain@icloud.com> (https://gitlab.com/FL03)
4    Description:
5        ... Summary ...
6*/
7use super::Configurable;
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
11pub struct Context<Cnf: Configurable> {
12    pub settings: Cnf,
13}
14
15impl<Cnf: Configurable> Context<Cnf> {
16    pub fn new(settings: Cnf) -> Self {
17        Self { settings }
18    }
19}
20
21impl<Cnf: Configurable> std::fmt::Display for Context<Cnf> {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        write!(f, "{}", serde_json::to_string_pretty(&self).unwrap())
24    }
25}