pub struct LogNormalizedDelayPerPacketConfig {
pub mean: Option<Delay>,
pub std_dev: Option<Delay>,
pub upper_bound: Option<Delay>,
pub lower_bound: Option<Delay>,
pub count: usize,
pub seed: Option<u64>,
}
Expand description
The configuration struct for LogNormalizedDelayPerPacket
.
See LogNormalizedDelayPerPacket
for more details.
Fields§
§mean: Option<Delay>
§std_dev: Option<Delay>
§upper_bound: Option<Delay>
§lower_bound: Option<Delay>
§count: usize
§seed: Option<u64>
Implementations§
Source§impl LogNormalizedDelayPerPacketConfig
impl LogNormalizedDelayPerPacketConfig
Sourcepub fn mean(self, mean: Delay) -> Self
pub fn mean(self, mean: Delay) -> Self
Sets the mean
If the mean is not set, 10ms will be used.
Sourcepub fn std_dev(self, std_dev: Delay) -> Self
pub fn std_dev(self, std_dev: Delay) -> Self
Sets the standard deviation
If the standard deviation is not set, 0ms will be used.
Sourcepub fn upper_bound(self, upper_bound: Delay) -> Self
pub fn upper_bound(self, upper_bound: Delay) -> Self
Sets the upper bound
If the upper bound is not set, the upper bound will be the one of Delay
.
Sourcepub fn lower_bound(self, lower_bound: Delay) -> Self
pub fn lower_bound(self, lower_bound: Delay) -> Self
Sets the lower bound
If the lower bound is not set, 0ms will be used.
Sourcepub fn count(self, count: usize) -> Self
pub fn count(self, count: usize) -> Self
Sets the number of packets to repeat
If the count is not set, it will be set to 0 (ie, infinite repeat).
Sourcepub fn seed(self, seed: u64) -> Self
pub fn seed(self, seed: u64) -> Self
Set the seed for a random generator
If the seed is not set, 42
will be used.
Sourcepub fn random_seed(self) -> Self
pub fn random_seed(self) -> Self
Allows to use a randomly generated seed
This is equivalent to: self.seed(rand::random())
Sourcepub fn build(self) -> LogNormalizedDelayPerPacket
pub fn build(self) -> LogNormalizedDelayPerPacket
Creates a new LogNormalizedDelayPerPacket
corresponding to this config.
The created model will use StdRng
as source of randomness (the call is equivalent to self.build_with_rng::<StdRng>()
).
It should be sufficient for most cases, but StdRng
is not a portable random number generator,
so one may want to use a portable random number generator like ChaCha
,
to this end one can use build_with_rng
.
Sourcepub fn build_with_rng<Rng: SeedableRng + RngCore>(
self,
) -> LogNormalizedDelayPerPacket<Rng>
pub fn build_with_rng<Rng: SeedableRng + RngCore>( self, ) -> LogNormalizedDelayPerPacket<Rng>
Creates a new LogNormalizedDelayPerPacket
corresponding to this config.
Unlike build
, this method let you choose the random generator.
§Example
let log_normal_delay = LogNormalizedDelayPerPacketConfig::new()
.mean(Delay::from_millis(12))
.std_dev(Delay::from_millis(1))
.count(3)
.seed(42);
let mut default_build = log_normal_delay.clone().build();
let mut std_build = log_normal_delay.clone().build_with_rng::<StdRng>();
// ChaCha is deterministic and portable, unlike StdRng
let mut chacha_build = log_normal_delay.clone().build_with_rng::<ChaCha20Rng>();
for cha in [12003077, 11716668, 11238761] {
let default = default_build.next_delay();
let std = std_build.next_delay();
let chacha = chacha_build.next_delay();
assert!(default.is_some());
assert_eq!(default, std);
assert_ne!(default, chacha);
assert_eq!(chacha, Some(Delay::from_nanos(cha)));
}
assert_eq!(default_build.next_delay(), None);
assert_eq!(std_build.next_delay(), None);
assert_eq!(chacha_build.next_delay(), None);
Trait Implementations§
Source§impl Clone for LogNormalizedDelayPerPacketConfig
impl Clone for LogNormalizedDelayPerPacketConfig
Source§fn clone(&self) -> LogNormalizedDelayPerPacketConfig
fn clone(&self) -> LogNormalizedDelayPerPacketConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for LogNormalizedDelayPerPacketConfig
impl Default for LogNormalizedDelayPerPacketConfig
Source§fn default() -> LogNormalizedDelayPerPacketConfig
fn default() -> LogNormalizedDelayPerPacketConfig
Source§impl DelayPerPacketTraceConfig for LogNormalizedDelayPerPacketConfig
impl DelayPerPacketTraceConfig for LogNormalizedDelayPerPacketConfig
fn into_model( self: Box<LogNormalizedDelayPerPacketConfig>, ) -> Box<dyn DelayPerPacketTrace>
Source§impl<'de> Deserialize<'de> for LogNormalizedDelayPerPacketConfig
impl<'de> Deserialize<'de> for LogNormalizedDelayPerPacketConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for LogNormalizedDelayPerPacketConfig
impl PartialEq for LogNormalizedDelayPerPacketConfig
Source§fn eq(&self, other: &LogNormalizedDelayPerPacketConfig) -> bool
fn eq(&self, other: &LogNormalizedDelayPerPacketConfig) -> bool
self
and other
values to be equal, and is used by ==
.impl Copy for LogNormalizedDelayPerPacketConfig
impl StructuralPartialEq for LogNormalizedDelayPerPacketConfig
Auto Trait Implementations§
impl Freeze for LogNormalizedDelayPerPacketConfig
impl RefUnwindSafe for LogNormalizedDelayPerPacketConfig
impl Send for LogNormalizedDelayPerPacketConfig
impl Sync for LogNormalizedDelayPerPacketConfig
impl Unpin for LogNormalizedDelayPerPacketConfig
impl UnwindSafe for LogNormalizedDelayPerPacketConfig
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
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 moreSource§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.