pub struct DelaySampler<S>where
S: DurationSampler,{ /* private fields */ }Expand description
A sampler that delays the output of a base sampler by adding the value from a delay sampler.
If the delay sampler returns a negative value, it is treated as zero, meaning the delay is not applied. If you need to support negative values (e.g., to accelerate the schedule), use JitterSampler instead.
Implementations§
Source§impl<S> DelaySampler<S>where
S: DurationSampler,
impl<S> DelaySampler<S>where
S: DurationSampler,
Sourcepub fn new(sampler: S, delay_sampler: Box<dyn DurationSampler>) -> Self
pub fn new(sampler: S, delay_sampler: Box<dyn DurationSampler>) -> Self
Creates a new DelaySampler.
Trait Implementations§
Source§impl<S> DurationSampler for DelaySampler<S>where
S: DurationSampler,
impl<S> DurationSampler for DelaySampler<S>where
S: DurationSampler,
Auto Trait Implementations§
impl<S> Freeze for DelaySampler<S>where
S: Freeze,
impl<S> !RefUnwindSafe for DelaySampler<S>
impl<S> !Send for DelaySampler<S>
impl<S> !Sync for DelaySampler<S>
impl<S> Unpin for DelaySampler<S>where
S: Unpin,
impl<S> UnsafeUnpin for DelaySampler<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for DelaySampler<S>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CombinatorExt for Twhere
T: DurationSampler + 'static,
impl<T> CombinatorExt for Twhere
T: DurationSampler + 'static,
Source§fn boxed(self) -> Box<dyn DurationSampler>
fn boxed(self) -> Box<dyn DurationSampler>
Boxes the sampler into a
Box<dyn DurationSampler> to erase its concrete type.Source§fn 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.Source§fn 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.Source§fn 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.
Source§fn 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.
Source§fn 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.Source§fn 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.Source§fn 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.Source§fn 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].Source§fn 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. Read more
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>
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 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>
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