Skip to main content

BackendExt

Trait BackendExt 

Source
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§

Source

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,

A convenience method for calling poll_next and decoding the Args in one step, returning a Task<Self::Args, ..> instead of Task<Self::Compact, ..>.

Source

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.

Source

fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
where Self: Sized, F: Fn(&Self::Error),

Attaches a callback F to be run on each error produced while polling the backend.

Source

fn map_err<F, E2>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: Fn(Self::Error) -> E2,

Maps errors produced by the backend from Self::Error into E2, useful for heterogeneous composed backends.

Source

fn with_codec<NewCodec>(self, codec: NewCodec) -> WithCodec<Self, NewCodec>
where Self: Sized + BackendConfig, NewCodec: Codec<Self::Args>,

Swaps out the backend’s serialization codec entirely (JSON, MessagePack, Protobuf, …) without touching storage logic.

Source

fn poll_with_stream<S>(self, stream: S) -> PollWith<Self, StreamStrategy<S>>
where Self: Sized, S: Stream + Unpin + Send + 'static,

Wake the worker when a stream receives a new item

Source

fn poll_with_interval( self, duration: Duration, ) -> PollWith<Self, IntervalStrategy>
where Self: Sized,

Available on crate feature sleep only.

Wake the worker periodically

Source

fn poll_with_backoff( self, interval: Duration, config: BackoffConfig, ) -> PollWith<Self, BackoffStrategy>
where Self: Sized,

Available on crate feature sleep only.

Wake the worker periodically with a backoff

Source

fn poll_with_strategy<S>(self, strategy: S) -> PollWith<Self, S>
where Self: Sized, S: PollStrategy,

Wake the worker with a custom strategy

Source

fn instrumented(self, span: Span) -> Instrumented<Self>
where Self: Sized,

Available on crate feature tracing only.

Provides a span to decorate emitted events

Source

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,

Runs an async callback once, before the backend’s first poll_ready is delegated.

Source

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,

Runs an async callback once, before the backend’s poll_close is called.

Source

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,

Runs an async callback once, after the backend’s first poll_ready is successful.

Source

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,

Runs an async callback once, after the worker has stopped and backend has cleaned up.

Source

fn interleave<S>(self, stream: S) -> Interleave<Self, S>
where Self: Sized, S: Stream<Item = Result<Self::Task, Self::Error>> + Unpin,

Interleaves the external stream with the backend.

Source

fn wake_on_push(self) -> WakeOnPush<Self>
where Self: Sized,

Wakes the worker when a new item is pushed

Source

fn shared(self) -> Shared<Self>
where Self: WireFormatBackend + Send, Self::Codec: Clone,

Available on crate feature 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".

Implementors§