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§
Sourcefn push(
&mut self,
task: Args,
) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send
fn push( &mut self, task: Args, ) -> impl Future<Output = Result<(), TaskSinkError<Self::Error>>> + Send
Allows pushing a single task into the backend
Sourcefn push_bulk(
&mut self,
tasks: Vec<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
Allows pushing multiple tasks into the backend in bulk
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.