pub trait CombinatorExt:
DurationSampler
+ Sized
+ 'static {
// Provided methods
fn boxed(self) -> Box<dyn DurationSampler> { ... }
fn boxed_clonable(self) -> Box<dyn ClonableDurationSampler>
where Self: Clone + Send + Sync { ... }
fn map<F>(self, f: F) -> MapSampler<Self, F>
where F: FnMut(&mut dyn Rng, SimTime, f64) -> f64 { ... }
fn delay(self, delay: Box<dyn DurationSampler>) -> DelaySampler<Self> { ... }
fn jitter(self, jitter: Box<dyn DurationSampler>) -> JitterSampler<Self> { ... }
fn chain<F>(
self,
sampler: Box<dyn DurationSampler>,
f: F,
) -> ChainSampler<Self, F>
where F: FnMut(&mut dyn Rng, SimTime, f64, f64) -> f64 { ... }
fn aggregate<F>(
self,
others: impl IntoIterator<Item = Box<dyn DurationSampler>>,
f: F,
) -> AggregateSampler<F>
where F: FnMut(&mut dyn Rng, SimTime, Vec<f64>) -> f64 { ... }
fn aggregate_builder(self) -> AggregateBuilder { ... }
fn clamp(self, min: f64, max: f64) -> ClampSampler<Self> { ... }
fn ensure_non_negative<F>(
self,
limit_try_count: u8,
fallback: F,
) -> EnsureNonNegativeSampler<Self, F>
where F: FnMut(&mut dyn Rng, SimTime) -> Duration { ... }
}Expand description
An extension trait for DurationSampler that provides fluent combinator methods for creating and composing complex duration sampling logic.
Provided Methods§
Sourcefn boxed(self) -> Box<dyn DurationSampler>
fn boxed(self) -> Box<dyn DurationSampler>
Boxes the sampler into a Box<dyn DurationSampler> to erase its concrete type.
Sourcefn boxed_clonable(self) -> Box<dyn ClonableDurationSampler>
fn boxed_clonable(self) -> Box<dyn ClonableDurationSampler>
Boxes the sampler as a cloneable trait object.
Requires the underlying sampler to be Clone, Send, and Sync.
Sourcefn map<F>(self, f: F) -> MapSampler<Self, F>
fn map<F>(self, f: F) -> MapSampler<Self, F>
Transforms the output of this sampler using the provided closure f.
Sourcefn delay(self, delay: Box<dyn DurationSampler>) -> DelaySampler<Self>
fn delay(self, delay: Box<dyn DurationSampler>) -> DelaySampler<Self>
Adds a delay to the result of this sampler using another sampler for the duration.
Sourcefn jitter(self, jitter: Box<dyn DurationSampler>) -> JitterSampler<Self>
fn jitter(self, jitter: Box<dyn DurationSampler>) -> JitterSampler<Self>
Adds a jitter (noise) to the result of this sampler using another sampler for the variation.
Sourcefn chain<F>(
self,
sampler: Box<dyn DurationSampler>,
f: F,
) -> ChainSampler<Self, F>
fn chain<F>( self, sampler: Box<dyn DurationSampler>, f: F, ) -> ChainSampler<Self, F>
Chains this sampler with another, combining their outputs using the provided closure f.
Sourcefn aggregate<F>(
self,
others: impl IntoIterator<Item = Box<dyn DurationSampler>>,
f: F,
) -> AggregateSampler<F>
fn aggregate<F>( self, others: impl IntoIterator<Item = Box<dyn DurationSampler>>, f: F, ) -> AggregateSampler<F>
Aggregates the results of this sampler and a collection of others into a single value
using the provided closure f.
Sourcefn aggregate_builder(self) -> AggregateBuilder
fn aggregate_builder(self) -> AggregateBuilder
Returns an AggregateBuilder initialized with this sampler, allowing for
a more flexible construction of aggregate samplers.
Sourcefn clamp(self, min: f64, max: f64) -> ClampSampler<Self>
fn clamp(self, min: f64, max: f64) -> ClampSampler<Self>
Clamps the output of this sampler within the range [min, max].
Sourcefn ensure_non_negative<F>(
self,
limit_try_count: u8,
fallback: F,
) -> EnsureNonNegativeSampler<Self, F>
fn ensure_non_negative<F>( self, limit_try_count: u8, fallback: F, ) -> EnsureNonNegativeSampler<Self, F>
Ensures the sampled duration is non-negative.
If the value remains negative after limit_try_count attempts, the fallback closure is invoked.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.