pub struct Simulator<H: PublishHook = NoOpHook> { /* private fields */ }Implementations§
Source§impl Simulator<NoOpHook>
impl Simulator<NoOpHook>
Sourcepub fn new(
subscribers: HashMap<String, Box<dyn Subscriber>>,
initial_time: SystemTime,
initial_events: Vec<Vec<SimulatorEvent>>,
) -> Self
pub fn new( subscribers: HashMap<String, Box<dyn Subscriber>>, initial_time: SystemTime, initial_events: Vec<Vec<SimulatorEvent>>, ) -> Self
Creates a new simulator with the given subscribers, initial time, and initial events.
The number of queues is determined by the length of the initial_events vector, and this must match the number of queues in a crate::message_bus::MessageBus to accurately simulate the message bus.
Source§impl<H: PublishHook> Simulator<H>
impl<H: PublishHook> Simulator<H>
Sourcepub fn with_hook(
subscribers: HashMap<String, Box<dyn Subscriber>>,
initial_time: SystemTime,
initial_events: Vec<Vec<SimulatorEvent>>,
hook: H,
) -> Self
pub fn with_hook( subscribers: HashMap<String, Box<dyn Subscriber>>, initial_time: SystemTime, initial_events: Vec<Vec<SimulatorEvent>>, hook: H, ) -> Self
Creates a new simulator with the given subscribers, initial time, initial events, and publish hook.
The number of queues is determined by the length of the initial_events vector, and this must match the number of queues in a crate::message_bus::MessageBus to accurately simulate the message bus.
Sourcepub fn step(&mut self, step_by: Duration) -> SystemTime
pub fn step(&mut self, step_by: Duration) -> SystemTime
Steps the simluator by some duration, looping through all of the subscribers to process events from the queue, then run their tick.
Returns the new time after the step.
pub fn step_to(&mut self, time: SystemTime, step_by: Duration) -> SystemTime
Auto Trait Implementations§
impl<H = NoOpHook> !RefUnwindSafe for Simulator<H>
impl<H = NoOpHook> !Sync for Simulator<H>
impl<H = NoOpHook> !UnwindSafe for Simulator<H>
impl<H> Freeze for Simulator<H>where
H: Freeze,
impl<H> Send for Simulator<H>
impl<H> Unpin for Simulator<H>where
H: Unpin,
impl<H> UnsafeUnpin for Simulator<H>where
H: UnsafeUnpin,
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