pub struct SimContext { /* private fields */ }Expand description
Simulation context provided to workloads.
Wraps all simulation infrastructure into a single, non-generic struct.
For code generic over P: Providers, pass ctx.providers().
Implementations§
Source§impl SimContext
impl SimContext
Sourcepub fn new(
providers: SimProviders,
topology: WorkloadTopology,
state: StateHandle,
) -> Self
pub fn new( providers: SimProviders, topology: WorkloadTopology, state: StateHandle, ) -> Self
Create a new simulation context.
Sourcepub fn providers(&self) -> &SimProviders
pub fn providers(&self) -> &SimProviders
Get the full providers bundle for passing to generic code.
Sourcepub fn network(&self) -> &SimNetworkProvider
pub fn network(&self) -> &SimNetworkProvider
Get the simulated network provider.
Sourcepub fn time(&self) -> &SimTimeProvider
pub fn time(&self) -> &SimTimeProvider
Get the simulated time provider.
Sourcepub fn task(&self) -> &TokioTaskProvider
pub fn task(&self) -> &TokioTaskProvider
Get the task provider.
Sourcepub fn random(&self) -> &SimRandomProvider
pub fn random(&self) -> &SimRandomProvider
Get the seeded random provider.
Sourcepub fn storage(&self) -> &SimStorageProvider
pub fn storage(&self) -> &SimStorageProvider
Get the simulated storage provider.
Sourcepub fn client_id(&self) -> usize
pub fn client_id(&self) -> usize
Get this workload’s client ID.
Assigned by the builder’s ClientId strategy.
Defaults to sequential IDs starting from 0 (FDB-style).
Sourcepub fn client_count(&self) -> usize
pub fn client_count(&self) -> usize
Get the total number of workload instances sharing this entry.
For single .workload() entries this is 1.
For .workloads(count, factory) entries this is the resolved count.
Sourcepub fn shutdown(&self) -> &CancellationToken
pub fn shutdown(&self) -> &CancellationToken
Get the shutdown cancellation token.
Sourcepub fn topology(&self) -> &WorkloadTopology
pub fn topology(&self) -> &WorkloadTopology
Get the workload topology (peer IPs, process IPs, tags, etc.).
Sourcepub fn state(&self) -> &StateHandle
pub fn state(&self) -> &StateHandle
Get the shared state handle for cross-workload communication.