pub trait SimNode<const N: usize, const Q: usize> {
type Error: Debug;
// Required methods
fn address(&self) -> &NodeAddress;
fn handle(
&mut self,
src: &NodeAddress,
data: &[u8],
now: Instant,
) -> Result<(), Self::Error>;
fn tick(&mut self, now: Instant) -> Result<(), Self::Error>;
fn drain_outbox(
&mut self,
out: &mut Vec<(NodeAddress, Vec<u8, N>), Q>,
) -> usize;
}Expand description
A participant in the simulation - either a sever (ECU) or client (tester).
Each node is a pure state machine. It receives messages via handle, produces outbound
messages via drain_outbox, and can be ticket for time-based state transitions.
N - max message payload bytes
Q - max messages in outbox simultaneously
Required Associated Types§
Required Methods§
Sourcefn address(&self) -> &NodeAddress
fn address(&self) -> &NodeAddress
Returns this node’s address on the simulation bus.
Sourcefn handle(
&mut self,
src: &NodeAddress,
data: &[u8],
now: Instant,
) -> Result<(), Self::Error>
fn handle( &mut self, src: &NodeAddress, data: &[u8], now: Instant, ) -> Result<(), Self::Error>
Delivers an inbound message to the node.
Sourcefn tick(&mut self, now: Instant) -> Result<(), Self::Error>
fn tick(&mut self, now: Instant) -> Result<(), Self::Error>
Advances the node’s internal state to the given time.
Used to trigger timeouts and retries. Called by the simulation bus on every tick even if no messages were delivered.
Sourcefn drain_outbox(&mut self, out: &mut Vec<(NodeAddress, Vec<u8, N>), Q>) -> usize
fn drain_outbox(&mut self, out: &mut Vec<(NodeAddress, Vec<u8, N>), Q>) -> usize
Drains all pending outbound messages from the node’s outbox.
Return an iterator of (dst, data) pairs. The bus calls this after every handle and
tick call to collect and route output.