pub struct SimBus<const N: usize, const Q: usize> { /* private fields */ }Expand description
The simulation message bus.
Connects all nodes in the simulation. Drives time forward, delivers messages, and injects
faults according to FaultConfig.
N - max message payload bytes
Q - max messages in-flight simultaneously
Implementations§
Source§impl<const N: usize, const Q: usize> SimBus<N, Q>
impl<const N: usize, const Q: usize> SimBus<N, Q>
pub fn new(seed: u64, faults: FaultConfig) -> Self
Sourcepub fn tick(&mut self, duration: Duration) -> Vec<Envelope<N>, Q>
pub fn tick(&mut self, duration: Duration) -> Vec<Envelope<N>, Q>
Advances simulation time by duration and returns all messages that are due for delivery
at or before the new time.
Sourcepub fn send(&mut self, src: NodeAddress, dst: NodeAddress, data: &[u8]) -> bool
pub fn send(&mut self, src: NodeAddress, dst: NodeAddress, data: &[u8]) -> bool
Enqueues a message from src to dst with fault injection applied.
Returns true if the message was enqueued, false if it was dropped by fault injection or
the queue is full
Sourcepub fn faults(&self) -> &FaultConfig
pub fn faults(&self) -> &FaultConfig
Returns a reference to the current fault config
Sourcepub fn set_faults(&mut self, faults: FaultConfig)
pub fn set_faults(&mut self, faults: FaultConfig)
Returns the fault config - allows escalating fault severity during a simulation run.
Sourcepub fn next_u8(&mut self) -> u8
pub fn next_u8(&mut self) -> u8
Returns the RNG seed-derived next value - useful for injecting spontaneous NRCs at the node level.
pub fn chance(&mut self, numerator: u32, denominator: u32) -> bool
Auto Trait Implementations§
impl<const N: usize, const Q: usize> Freeze for SimBus<N, Q>
impl<const N: usize, const Q: usize> RefUnwindSafe for SimBus<N, Q>
impl<const N: usize, const Q: usize> Send for SimBus<N, Q>
impl<const N: usize, const Q: usize> Sync for SimBus<N, Q>
impl<const N: usize, const Q: usize> Unpin for SimBus<N, Q>
impl<const N: usize, const Q: usize> UnsafeUnpin for SimBus<N, Q>
impl<const N: usize, const Q: usize> UnwindSafe for SimBus<N, Q>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more