pub struct RotateSampler { /* private fields */ }Expand description
A sampler that returns durations from a fixed list in a cyclic (rotating) order.
§Note
This sampler maintains internal state (next_index). If you re-instantiate
this sampler frequently, the sequence will always start from the beginning.
Implementations§
Source§impl RotateSampler
impl RotateSampler
Sourcepub fn new(
duration_list: impl IntoIterator<Item = PendingDuration>,
) -> RotateSampler
pub fn new( duration_list: impl IntoIterator<Item = PendingDuration>, ) -> RotateSampler
Creates a new RotateSampler starting from the first element.
Sourcepub fn new_with_index(
duration_list: impl IntoIterator<Item = PendingDuration>,
next_index: usize,
) -> RotateSampler
pub fn new_with_index( duration_list: impl IntoIterator<Item = PendingDuration>, next_index: usize, ) -> RotateSampler
Creates a new RotateSampler starting from a specific index.
Sourcepub fn peek_next_index(&self) -> usize
pub fn peek_next_index(&self) -> usize
Returns the index of the next duration to be sampled.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Returns the total number of items in the rotation list.
Trait Implementations§
Source§impl Clone for RotateSampler
impl Clone for RotateSampler
Source§fn clone(&self) -> RotateSampler
fn clone(&self) -> RotateSampler
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 Debug for RotateSampler
impl Debug for RotateSampler
Source§impl DurationSampler for RotateSampler
impl DurationSampler for RotateSampler
Auto Trait Implementations§
impl Freeze for RotateSampler
impl RefUnwindSafe for RotateSampler
impl Send for RotateSampler
impl Sync for RotateSampler
impl Unpin for RotateSampler
impl UnsafeUnpin for RotateSampler
impl UnwindSafe for RotateSampler
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