Struct slottle::Interval[][src]

pub struct Interval { /* fields omitted */ }

The interval configuration.

Implementations

impl Interval[src]

pub fn new<F>(interval_fn: F, log_size: usize) -> Self where
    F: Fn(Option<&ThrottleLog>) -> Duration + Send + Sync + 'static, 
[src]

Create a interval calculating algorithm

Define an interval_fn to generate interval dynamically.

log_size argument determine the maximum size of ThrottleLog which interval_fn can access. If log_size == 0, interval_fn will receive None.

pub fn modify<F>(self, f: F) -> Interval where
    F: Fn(Duration) -> Duration + Send + Sync + 'static, 
[src]

Apply post-process to generated interval.

This method are useful when user want to do some tweaks with pre-built interval algorithm.

example

use std::time::Duration;
use slottle::Interval;

// following algorithm produce random duration from 0 ~ 10ms
let algo = Interval::new(|_| Duration::from_millis(10), 0)
    .modify(|dur| dur.mul_f64(rand::random()));

Trait Implementations

impl Clone for Interval[src]

impl Debug for Interval[src]

impl Default for Interval[src]

impl From<Duration> for Interval[src]

impl<F> From<F> for Interval where
    F: Fn() -> Duration + Send + Sync + 'static, 
[src]

Auto Trait Implementations

impl !RefUnwindSafe for Interval

impl Send for Interval

impl Sync for Interval

impl Unpin for Interval

impl !UnwindSafe for Interval

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.