Skip to main content

Simulator

Struct Simulator 

Source
pub struct Simulator<H: PublishHook = NoOpHook> { /* private fields */ }

Implementations§

Source§

impl Simulator<NoOpHook>

Source

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>

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.