pub struct EventContext<E, M: Model<E>> { /* private fields */ }Expand description
Holds and manages context information during event processing.
This provides access to the current simulation time, micro-step status, hook management, source handling, and the event scheduler during model execution.
Implementations§
Source§impl<E, M: Model<E>> EventContext<E, M>
impl<E, M: Model<E>> EventContext<E, M>
Sourcepub fn add_source<S>(&mut self, model: &M, name: &'static str, source: S)where
S: Source<E, M> + 'static,
pub fn add_source<S>(&mut self, model: &M, name: &'static str, source: S)where
S: Source<E, M> + 'static,
Registers a new source and adds it to the event processing loop.
§Arguments
model- The model associated with the source.name- A unique identifier for the source.source- The source implementation to register.
Sourcepub fn cancel_scheduled_sources<S, F>(
&mut self,
model: &M,
pred: F,
) -> Vec<(SimTime, SourceReadyEntry)>
pub fn cancel_scheduled_sources<S, F>( &mut self, model: &M, pred: F, ) -> Vec<(SimTime, SourceReadyEntry)>
Trait Implementations§
Source§impl<E, M: Model<E>> UserContext<E, M> for EventContext<E, M>
impl<E, M: Model<E>> UserContext<E, M> for EventContext<E, M>
Source§fn current_tick(&self) -> SimTime
fn current_tick(&self) -> SimTime
Returns the current simulation tick (absolute time).
Source§fn current_micro_step(&self) -> MicroStep
fn current_micro_step(&self) -> MicroStep
Returns the current micro-step (the index of the step within the current tick).
Source§fn schedule_event(
&mut self,
delay: Duration,
priority: EventPriority,
event_payload: E,
)
fn schedule_event( &mut self, delay: Duration, priority: EventPriority, event_payload: E, )
Schedules an event with the specified delay and priority. Read more
Auto Trait Implementations§
impl<E, M> Freeze for EventContext<E, M>
impl<E, M> !RefUnwindSafe for EventContext<E, M>
impl<E, M> !Send for EventContext<E, M>
impl<E, M> !Sync for EventContext<E, M>
impl<E, M> Unpin for EventContext<E, M>where
E: Unpin,
impl<E, M> UnsafeUnpin for EventContext<E, M>
impl<E, M> !UnwindSafe for EventContext<E, M>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more