pub struct EnsureNonNegativeSampler<S, F>{ /* private fields */ }Expand description
A sampler that ensures the sampled duration is non-negative.
It attempts to sample from the base sampler up to limit_try_count times.
If all attempts return a negative value, it falls back to the result of the
fallback closure.
Implementations§
Trait Implementations§
Source§impl<S, F> Clone for EnsureNonNegativeSampler<S, F>
impl<S, F> Clone for EnsureNonNegativeSampler<S, F>
Source§fn clone(&self) -> EnsureNonNegativeSampler<S, F>
fn clone(&self) -> EnsureNonNegativeSampler<S, F>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S, F> Debug for EnsureNonNegativeSampler<S, F>
impl<S, F> Debug for EnsureNonNegativeSampler<S, F>
Source§impl<S, F> DurationSampler for EnsureNonNegativeSampler<S, F>
impl<S, F> DurationSampler for EnsureNonNegativeSampler<S, F>
Auto Trait Implementations§
impl<S, F> Freeze for EnsureNonNegativeSampler<S, F>
impl<S, F> RefUnwindSafe for EnsureNonNegativeSampler<S, F>where
S: RefUnwindSafe,
F: RefUnwindSafe,
impl<S, F> Send for EnsureNonNegativeSampler<S, F>
impl<S, F> Sync for EnsureNonNegativeSampler<S, F>
impl<S, F> Unpin for EnsureNonNegativeSampler<S, F>
impl<S, F> UnsafeUnpin for EnsureNonNegativeSampler<S, F>where
S: UnsafeUnpin,
F: UnsafeUnpin,
impl<S, F> UnwindSafe for EnsureNonNegativeSampler<S, F>where
S: UnwindSafe,
F: UnwindSafe,
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<S> ClonableDurationSampler for S
impl<S> ClonableDurationSampler for S
fn box_clone(&self) -> Box<dyn ClonableDurationSampler>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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