use crate::actor::State;
use crate::message::Message;
use crate::operator::OperatorResult;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::ops::Add;
pub trait Gene<T: Add<Output = T>> {
fn apply_operators(&self, state: State<T>, update: Message<T>) -> OperatorResult<State<T>>;
fn get_time_scope(&self) -> &TimeScope;
}
#[allow(clippy::module_name_repetitions)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum GeneType {
Accum,
Gauge,
GaugeAndAccum,
Default,
}
impl fmt::Display for GeneType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let display_text = match self {
Self::Accum => "[Accum Gene]",
Self::Gauge => "[GaugeGene]",
Self::GaugeAndAccum => "[GaugeAndAccum Gene]",
Self::Default => "[Default GaugeGene]",
};
write!(f, "{display_text}")
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum TimeScope {
Forever,
Year,
Month,
Day,
HalfDay,
QuarterDay,
Hour,
QuarterHour,
TenMinutes,
Minute,
}
impl fmt::Display for TimeScope {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let display_text = match self {
Self::Forever => "[Forever Time Scope]",
Self::Year => "[Year Time Scope]",
Self::Month => "[Month Time Scope]",
Self::Day => "[Day Time Scope]",
Self::HalfDay => "[Half Day Time Scope]",
Self::QuarterDay => "[Quarter Day Time Scope]",
Self::Hour => "[Hour Time Scope]",
Self::TenMinutes => "[Ten Minute Time Scope]",
_ => "[Minute Time Scope]",
};
write!(f, "{display_text}")
}
}