Skip to main content

RunnableExt

Trait RunnableExt 

Source
pub trait RunnableExt<I, O>: Runnable<I, O> + Sized
where I: Send + 'static, O: Send + 'static,
{ // Provided methods fn pipe<R2, O2>(self, next: R2) -> Pipe<Self, R2, I, O, O2> where R2: Runnable<O, O2>, O2: Send + 'static { ... } fn with_retry(self, policy: RetryPolicy) -> Retry<Self, I, O> where I: Clone { ... } fn with_max_retries(self, attempts: u32) -> Retry<Self, I, O> where I: Clone { ... } fn with_timeout(self, duration: Duration) -> Timeout<Self, I, O> { ... } fn with_fallback<F>(self, fallback: F) -> Fallback<Self, F, I, O> where F: Runnable<I, O>, I: Clone { ... } fn with_memory_cache<K, F>( self, key_fn: F, ) -> Cache<Self, I, O, K, MemoryCache<K, O>> where K: Hash + Eq + Clone + Send + Sync + 'static, O: Clone + Send + Sync + 'static, F: Fn(&I) -> K + Send + Sync + 'static { ... } fn each(self) -> Each<Self, I, O> { ... } }
Expand description

Adds composition + wrapper methods to any Runnable.

Provided Methods§

Source

fn pipe<R2, O2>(self, next: R2) -> Pipe<Self, R2, I, O, O2>
where R2: Runnable<O, O2>, O2: Send + 'static,

Pipe this runnable into another, building a Pipe<Self, Next>.

Source

fn with_retry(self, policy: RetryPolicy) -> Retry<Self, I, O>
where I: Clone,

Wrap with a retry policy.

Source

fn with_max_retries(self, attempts: u32) -> Retry<Self, I, O>
where I: Clone,

Shortcut: retry with default policy and N attempts.

Source

fn with_timeout(self, duration: Duration) -> Timeout<Self, I, O>

Wrap with a per-call timeout.

Source

fn with_fallback<F>(self, fallback: F) -> Fallback<Self, F, I, O>
where F: Runnable<I, O>, I: Clone,

Wrap with a fallback runnable.

Source

fn with_memory_cache<K, F>( self, key_fn: F, ) -> Cache<Self, I, O, K, MemoryCache<K, O>>
where K: Hash + Eq + Clone + Send + Sync + 'static, O: Clone + Send + Sync + 'static, F: Fn(&I) -> K + Send + Sync + 'static,

Wrap with an in-memory cache keyed by key_fn(&I).

Source

fn each(self) -> Each<Self, I, O>

Apply this runnable to each element of a Vec<I> (preserves order).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<R, I, O> RunnableExt<I, O> for R
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,