pub trait BackendExt: Backend {
Show 17 methods
// Provided methods
fn poll_next_args(
&mut self,
cx: &mut Context<'_>,
worker: &WorkerContext,
) -> Poll<Option<Result<Task<Self::Args>, PollNextArgsError<Self>>>>
where Self: Sized + BackendConfig + WireFormatBackend + Backend<Task = Task<Self::Compact>>,
Self::Codec: Codec<Self::Args, Compact = Self::Compact>,
<Self::Codec as Codec<Self::Args>>::Error: Error + Send + Sync + 'static { ... }
fn pipe_to<Dst>(self, backend: Dst) -> Pipe<Dst, Self>
where Self: Sized { ... }
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
where Self: Sized,
F: Fn(&Self::Error) { ... }
fn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
where Self: Sized,
F: Fn(Self::Error) -> E2 { ... }
fn with_codec<NewCodec>(self, codec: NewCodec) -> WithCodec<Self, NewCodec>
where Self: Sized + BackendConfig,
NewCodec: Codec<Self::Args> { ... }
fn poll_with_stream<S>(self, stream: S) -> PollWith<Self, StreamStrategy<S>>
where Self: Sized,
S: Stream + Unpin + Send + 'static { ... }
fn poll_with_interval(
self,
duration: Duration,
) -> PollWith<Self, IntervalStrategy>
where Self: Sized { ... }
fn poll_with_backoff(
self,
interval: Duration,
config: BackoffConfig,
) -> PollWith<Self, BackoffStrategy>
where Self: Sized { ... }
fn poll_with_strategy<S>(self, strategy: S) -> PollWith<Self, S>
where Self: Sized,
S: PollStrategy { ... }
fn instrumented(self, span: Span) -> Instrumented<Self>
where Self: Sized { ... }
fn before_start<F, Fut>(self, f: F) -> BeforeStart<Self, Self::Error>
where Self: Sized,
F: Fn(&mut Self) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), Self::Error>> + Send + 'static { ... }
fn before_stop<F, Fut>(self, f: F) -> BeforeStop<Self, Self::Error>
where Self: Sized,
F: Fn(&mut Self) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), Self::Error>> + Send + 'static { ... }
fn after_start<F, Fut>(self, f: F) -> AfterStart<Self, Self::Error>
where Self: Sized,
for<'c> F: Fn(&mut Self) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), Self::Error>> + Send + 'static { ... }
fn after_stop<F, Fut>(self, f: F) -> AfterStop<Self, Self::Error>
where Self: Sized,
F: Fn(&mut Self) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), Self::Error>> + Send + 'static { ... }
fn interleave<S>(self, stream: S) -> Interleave<Self, S>
where Self: Sized,
S: Stream<Item = Result<Self::Task, Self::Error>> + Unpin { ... }
fn wake_on_push(self) -> WakeOnPush<Self>
where Self: Sized { ... }
fn shared(self) -> Shared<Self>
where Self: WireFormatBackend + Send,
Self::Codec: Clone { ... }
}Expand description
Extension trait for Backend that provides additional combinators and utilities.
Provided Methods§
Sourcefn poll_next_args(
&mut self,
cx: &mut Context<'_>,
worker: &WorkerContext,
) -> Poll<Option<Result<Task<Self::Args>, PollNextArgsError<Self>>>>
fn poll_next_args( &mut self, cx: &mut Context<'_>, worker: &WorkerContext, ) -> Poll<Option<Result<Task<Self::Args>, PollNextArgsError<Self>>>>
A convenience method for calling poll_next and decoding the Args in one step,
returning a Task<Self::Args, ..> instead of Task<Self::Compact, ..>.
Sourcefn pipe_to<Dst>(self, backend: Dst) -> Pipe<Dst, Self>where
Self: Sized,
fn pipe_to<Dst>(self, backend: Dst) -> Pipe<Dst, Self>where
Self: Sized,
Pipes every task polled from this backend into sink
Useful for bridging two backend implementations — e.g. draining an ephemeral/legacy queue into a durable one, or fanning a lightweight source into a shared sink that multiple producers write into.
Sourcefn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Attaches a callback F to be run on each error produced while polling the backend.
Sourcefn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
Maps errors produced by the backend from Self::Error into E2, useful for
heterogeneous composed backends.
Sourcefn with_codec<NewCodec>(self, codec: NewCodec) -> WithCodec<Self, NewCodec>
fn with_codec<NewCodec>(self, codec: NewCodec) -> WithCodec<Self, NewCodec>
Swaps out the backend’s serialization codec entirely (JSON, MessagePack, Protobuf, …) without touching storage logic.
Sourcefn poll_with_stream<S>(self, stream: S) -> PollWith<Self, StreamStrategy<S>>
fn poll_with_stream<S>(self, stream: S) -> PollWith<Self, StreamStrategy<S>>
Wake the worker when a stream receives a new item
Sourcefn poll_with_interval(
self,
duration: Duration,
) -> PollWith<Self, IntervalStrategy>where
Self: Sized,
Available on crate feature sleep only.
fn poll_with_interval(
self,
duration: Duration,
) -> PollWith<Self, IntervalStrategy>where
Self: Sized,
sleep only.Wake the worker periodically
Sourcefn poll_with_backoff(
self,
interval: Duration,
config: BackoffConfig,
) -> PollWith<Self, BackoffStrategy>where
Self: Sized,
Available on crate feature sleep only.
fn poll_with_backoff(
self,
interval: Duration,
config: BackoffConfig,
) -> PollWith<Self, BackoffStrategy>where
Self: Sized,
sleep only.Wake the worker periodically with a backoff
Sourcefn poll_with_strategy<S>(self, strategy: S) -> PollWith<Self, S>where
Self: Sized,
S: PollStrategy,
fn poll_with_strategy<S>(self, strategy: S) -> PollWith<Self, S>where
Self: Sized,
S: PollStrategy,
Wake the worker with a custom strategy
Sourcefn instrumented(self, span: Span) -> Instrumented<Self>where
Self: Sized,
Available on crate feature tracing only.
fn instrumented(self, span: Span) -> Instrumented<Self>where
Self: Sized,
tracing only.Provides a span to decorate emitted events
Sourcefn before_start<F, Fut>(self, f: F) -> BeforeStart<Self, Self::Error>
fn before_start<F, Fut>(self, f: F) -> BeforeStart<Self, Self::Error>
Runs an async callback once, before the backend’s first poll_ready is delegated.
Sourcefn before_stop<F, Fut>(self, f: F) -> BeforeStop<Self, Self::Error>
fn before_stop<F, Fut>(self, f: F) -> BeforeStop<Self, Self::Error>
Runs an async callback once, before the backend’s poll_close is called.
Sourcefn after_start<F, Fut>(self, f: F) -> AfterStart<Self, Self::Error>
fn after_start<F, Fut>(self, f: F) -> AfterStart<Self, Self::Error>
Runs an async callback once, after the backend’s first poll_ready is successful.
Sourcefn after_stop<F, Fut>(self, f: F) -> AfterStop<Self, Self::Error>
fn after_stop<F, Fut>(self, f: F) -> AfterStop<Self, Self::Error>
Runs an async callback once, after the worker has stopped and backend has cleaned up.
Sourcefn interleave<S>(self, stream: S) -> Interleave<Self, S>
fn interleave<S>(self, stream: S) -> Interleave<Self, S>
Interleaves the external stream with the backend.
Sourcefn wake_on_push(self) -> WakeOnPush<Self>where
Self: Sized,
fn wake_on_push(self) -> WakeOnPush<Self>where
Self: Sized,
Wakes the worker when a new item is pushed
Available on crate feature shared only.
shared only.Create a cloneable handle to the inner backend where all handles are clone.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".