use crate::primitive::time::SimTime;
pub type SimulationResult<M, Err> = Result<SimulationOutput<M>, SimulationError<M, Err>>;
#[derive(Debug)]
pub struct SimulationOutput<M> {
time: SimTime,
model: M,
}
impl<M> SimulationOutput<M> {
pub(crate) fn new(time: SimTime, model: M) -> Self {
Self { time, model }
}
pub fn last_tick(&self) -> SimTime {
self.time
}
pub fn model(&self) -> &M {
&self.model
}
pub fn model_mut(&mut self) -> &mut M {
&mut self.model
}
}
#[derive(Debug)]
pub struct SimulationError<M, Err> {
time: SimTime,
model: M,
error: Err,
}
impl<M, Err> SimulationError<M, Err> {
pub(crate) fn new(time: SimTime, model: M, error: Err) -> Self {
Self { time, model, error }
}
pub fn last_tick(&self) -> SimTime {
self.time
}
pub fn model(&self) -> &M {
&self.model
}
pub fn model_mut(&mut self) -> &mut M {
&mut self.model
}
pub fn error(&self) -> &Err {
&self.error
}
pub fn error_mut(&mut self) -> &mut Err {
&mut self.error
}
}