pub struct SimConfig {
pub seed: u64,
pub fail_rate: f64,
pub repair_rate: f64,
pub tcp_capacity: u64,
pub udp_capacity: u64,
pub enable_random_order: bool,
pub min_message_latency: Duration,
pub max_message_latency: Duration,
pub duration: Duration,
pub tick_duration: Duration,
}Expand description
Configuration for a simulation run.
Controls various aspects of the simulation environment including randomness, failure rates, network properties, and timing.
Fields§
§seed: u64Random seed for reproducible simulations.
fail_rate: f64Probability (0.0 to 1.0) that a component will fail.
repair_rate: f64Probability (0.0 to 1.0) that a failed component will be repaired.
tcp_capacity: u64Maximum number of TCP messages in flight.
udp_capacity: u64Maximum number of UDP messages in flight.
enable_random_order: boolWhether to randomize the order of actor execution.
min_message_latency: DurationMinimum simulated network latency.
max_message_latency: DurationMaximum simulated network latency.
duration: DurationHow long the simulation should run (Duration::MAX for unlimited).
tick_duration: DurationDuration of each simulation tick.
Implementations§
Source§impl SimConfig
impl SimConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new SimConfig with default values.
Returns a configuration with reasonable defaults for testing.
Sourcepub fn from_rng() -> Self
pub fn from_rng() -> Self
Creates a new SimConfig with randomized values.
Uses the current RNG to generate configuration values suitable for
testing. The SIMULATOR_DURATION environment variable can be used
to override the duration.
§Panics
- If
SIMULATOR_DURATIONis set but cannot be parsed as a supported duration format.
§Examples
use simvar_harness::SimConfig;
let config = SimConfig::from_rng();
assert!(config.max_message_latency >= config.min_message_latency);Sourcepub const fn fail_rate(&mut self, fail_rate: f64) -> &mut Self
pub const fn fail_rate(&mut self, fail_rate: f64) -> &mut Self
Sets the failure rate (0.0 to 1.0) and returns a mutable reference to self.
Sourcepub const fn repair_rate(&mut self, repair_rate: f64) -> &mut Self
pub const fn repair_rate(&mut self, repair_rate: f64) -> &mut Self
Sets the repair rate (0.0 to 1.0) and returns a mutable reference to self.
Sourcepub const fn tcp_capacity(&mut self, tcp_capacity: u64) -> &mut Self
pub const fn tcp_capacity(&mut self, tcp_capacity: u64) -> &mut Self
Sets the TCP capacity and returns a mutable reference to self.
Sourcepub const fn udp_capacity(&mut self, udp_capacity: u64) -> &mut Self
pub const fn udp_capacity(&mut self, udp_capacity: u64) -> &mut Self
Sets the UDP capacity and returns a mutable reference to self.
Sourcepub const fn enable_random_order(
&mut self,
enable_random_order: bool,
) -> &mut Self
pub const fn enable_random_order( &mut self, enable_random_order: bool, ) -> &mut Self
Sets whether to enable random actor execution order and returns a mutable reference to self.
Sourcepub const fn min_message_latency(
&mut self,
min_message_latency: Duration,
) -> &mut Self
pub const fn min_message_latency( &mut self, min_message_latency: Duration, ) -> &mut Self
Sets the minimum message latency and returns a mutable reference to self.
Sourcepub const fn max_message_latency(
&mut self,
max_message_latency: Duration,
) -> &mut Self
pub const fn max_message_latency( &mut self, max_message_latency: Duration, ) -> &mut Self
Sets the maximum message latency and returns a mutable reference to self.
Sourcepub const fn duration(&mut self, duration: Duration) -> &mut Self
pub const fn duration(&mut self, duration: Duration) -> &mut Self
Sets the simulation duration and returns a mutable reference to self.
Sourcepub const fn tick_duration(&mut self, tick_duration: Duration) -> &mut Self
pub const fn tick_duration(&mut self, tick_duration: Duration) -> &mut Self
Sets the tick duration and returns a mutable reference to self.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimConfig
impl RefUnwindSafe for SimConfig
impl Send for SimConfig
impl Sync for SimConfig
impl Unpin for SimConfig
impl UnsafeUnpin for SimConfig
impl UnwindSafe for SimConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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