Skip to main content

SimConfig

Struct SimConfig 

Source
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: u64

Random seed for reproducible simulations.

§fail_rate: f64

Probability (0.0 to 1.0) that a component will fail.

§repair_rate: f64

Probability (0.0 to 1.0) that a failed component will be repaired.

§tcp_capacity: u64

Maximum number of TCP messages in flight.

§udp_capacity: u64

Maximum number of UDP messages in flight.

§enable_random_order: bool

Whether to randomize the order of actor execution.

§min_message_latency: Duration

Minimum simulated network latency.

§max_message_latency: Duration

Maximum simulated network latency.

§duration: Duration

How long the simulation should run (Duration::MAX for unlimited).

§tick_duration: Duration

Duration of each simulation tick.

Implementations§

Source§

impl SimConfig

Source

pub const fn new() -> Self

Creates a new SimConfig with default values.

Returns a configuration with reasonable defaults for testing.

Source

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_DURATION is 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);
Source

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.

Source

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.

Source

pub const fn tcp_capacity(&mut self, tcp_capacity: u64) -> &mut Self

Sets the TCP capacity and returns a mutable reference to self.

Source

pub const fn udp_capacity(&mut self, udp_capacity: u64) -> &mut Self

Sets the UDP capacity and returns a mutable reference to self.

Source

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.

Source

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.

Source

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.

Source

pub const fn duration(&mut self, duration: Duration) -> &mut Self

Sets the simulation duration and returns a mutable reference to self.

Source

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§

Source§

impl Clone for SimConfig

Source§

fn clone(&self) -> SimConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SimConfig

Source§

impl Debug for SimConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SimConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V