WeakTaskSink

Trait WeakTaskSink 

Source
pub trait WeakTaskSink<Args>: Backend {
    // Required methods
    fn push(
        &mut self,
        task: Args,
    ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send;
    fn push_bulk(
        &mut self,
        tasks: Vec<Args>,
    ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send;
    fn push_stream(
        &mut self,
        tasks: impl Stream<Item = Args> + Unpin + Send,
    ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send;
    fn push_task(
        &mut self,
        task: Task<Args, Self::Context, Self::IdType>,
    ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send;
}
Expand description

Extends Backend to allow pushing tasks into the backend without requiring compile time constraints. By default the TaskSink trait requires TaskSink<Args>: Backend<Args> which can be restrictive in certain scenarios. This means you cannot push tasks of different argument types using the same backend instance. The WeakTaskSink trait relaxes this constraint, allowing pushing tasks of any argument type as long as they match the backend’s context and ID type. This is useful for dynamic task management scenarios where tasks of varying types need to be pushed into the same backend instance.

Required Methods§

Source

fn push( &mut self, task: Args, ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send

Allows pushing a single task into the backend

Source

fn push_bulk( &mut self, tasks: Vec<Args>, ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send

Allows pushing multiple tasks into the backend in bulk

Source

fn push_stream( &mut self, tasks: impl Stream<Item = Args> + Unpin + Send, ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send

Allows pushing tasks from a stream into the backend

Source

fn push_task( &mut self, task: Task<Args, Self::Context, Self::IdType>, ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send

Allows pushing a fully constructed task into the backend

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<Args, S, E, C> WeakTaskSink<Args> for S
where S: Sink<Task<C::Compact, Self::Context, Self::IdType>, Error = E> + Unpin + Backend<Error = E, Codec = C> + Send, Args: Send, C::Compact: Send, S::Context: Send + Default, S::IdType: Send + 'static, C: Codec<Args>, E: Send, C::Error: Error + Send + Sync + 'static,