Struct slottle::Interval [−][src]
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]
F: Fn(Option<&ThrottleLog>) -> Duration + Send + Sync + 'static,
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]
F: Fn(Duration) -> Duration + Send + Sync + 'static,
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]
F: Fn() -> Duration + Send + Sync + 'static,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,