scsys_agents/core/states/
mod.rs

1/*
2    Appellation: states <module>
3    Creator: FL03 <jo3mccain@icloud.com>
4    Description:
5        ... Summary ...
6*/
7pub use self::{specs::*, state::*};
8
9pub(crate) mod state;
10
11pub(crate) mod specs {
12    use crate::messages::Message;
13    use serde::Serialize;
14
15    pub trait Stateful: Clone + Default + Serialize + std::fmt::Display {
16        type Data: std::fmt::Display;
17
18        fn message(&self) -> &Message<Self::Data>;
19        fn timestamp(&self) -> i64;
20    }
21
22    pub trait StatefulExt: Stateful {
23        fn agency(&self) -> String;
24        fn catalyst<S, T>(&mut self, f: &dyn Fn(S) -> T) -> Vec<T>;
25        fn tags(&self) -> Vec<String>;
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use super::State;
32
33    #[test]
34    fn test_state_default() {
35        let actual = State::from("test");
36        let expected = actual.clone();
37        assert_eq!(actual, expected)
38    }
39}