pub struct SimContext { /* private fields */ }Expand description
Central simulation context.
Holds the master seed, seed tree, logical clock, and event log for a
single simulation run. Pass a reference to SimContext into every
subsystem that needs deterministic randomness or event logging.
Implementations§
Source§impl SimContext
impl SimContext
Sourcepub fn new(seed: VortexSeed) -> Self
pub fn new(seed: VortexSeed) -> Self
Create a new simulation context from a master seed.
Sourcepub fn seed(&self) -> VortexSeed
pub fn seed(&self) -> VortexSeed
Get the master seed.
Sourcepub fn logical_time_us(&self) -> u64
pub fn logical_time_us(&self) -> u64
Get the current logical time in microseconds.
Sourcepub fn advance_time_us(&mut self, delta_us: u64)
pub fn advance_time_us(&mut self, delta_us: u64)
Advance logical time by the given microseconds.
Sourcepub fn set_time_us(&mut self, time_us: u64)
pub fn set_time_us(&mut self, time_us: u64)
Set logical time to an absolute value.
Sourcepub fn log_event(
&mut self,
subsystem: Subsystem,
description: impl Into<String>,
) -> SeqNo
pub fn log_event( &mut self, subsystem: Subsystem, description: impl Into<String>, ) -> SeqNo
Record an event in the event log.
Sourcepub fn log_event_with_payload(
&mut self,
subsystem: Subsystem,
description: impl Into<String>,
payload: Vec<u8>,
) -> SeqNo
pub fn log_event_with_payload( &mut self, subsystem: Subsystem, description: impl Into<String>, payload: Vec<u8>, ) -> SeqNo
Record an event with a payload.
Sourcepub fn event_log(&self) -> &SimEventLog
pub fn event_log(&self) -> &SimEventLog
Get a reference to the event log.
Sourcepub fn into_event_log(self) -> SimEventLog
pub fn into_event_log(self) -> SimEventLog
Take ownership of the event log (consumes the context).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimContext
impl RefUnwindSafe for SimContext
impl Send for SimContext
impl Sync for SimContext
impl Unpin for SimContext
impl UnsafeUnpin for SimContext
impl UnwindSafe for SimContext
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