Skip to main content

rustsim_core/
agent.rs

1//! Agent trait - the fundamental interface for all simulation entities.
2use crate::types::AgentId;
3
4/// The core trait that every agent type must implement.
5///
6/// An agent is any entity that participates in the simulation. The only
7/// requirement is a unique identifier accessible via [`Agent::id`].
8///
9/// # Example
10///
11/// ```
12/// use rustsim_core::prelude::*;
13///
14/// #[derive(Debug, Clone)]
15/// struct Particle {
16///     id: AgentId,
17///     x: f64,
18/// }
19///
20/// impl Agent for Particle {
21///     fn id(&self) -> AgentId { self.id }
22/// }
23/// ```
24pub trait Agent {
25    /// Returns the unique identifier for this agent.
26    fn id(&self) -> AgentId;
27}