Skip to main content

des_sim/modeling/
model.rs

1//! The `model` module defines the `Model` trait, which is the fundamental interface
2//! for any simulation model in `des-sim`.
3//!
4//! Any custom simulation logic must implement this trait to process events
5//! and interact with the simulation environment via the provided `EventContext`.
6
7use crate::context::EventContext;
8use crate::modeling::event::Event;
9
10/// Defines the interface for a simulation model that processes events.
11///
12/// Models implementing this trait are responsible for reacting to events
13/// triggered within the simulation and updating their internal state accordingly.
14pub trait Model<E>: Sized {
15    /// Handles an incoming event within the provided simulation context.
16    ///
17    /// # Arguments
18    ///
19    /// * `context` - The simulation context, providing access to state, scheduling, and hooks.
20    /// * `event` - The event to be processed by this model.
21    fn handle_event(&mut self, context: &mut EventContext<E, Self>, event: &Event<E>);
22}