Trait messaging_thread_pool::SenderAndReceiver

source ·
pub trait SenderAndReceiver<P>
where P: PoolItem,
{ // Required method fn send_and_receive<'a, T>( &'a self, requests: impl Iterator<Item = T> + 'a ) -> Result<Box<dyn Iterator<Item = T::Response> + 'a>, SendError<SenderCouplet<P>>> where T: RequestWithResponse<P> + IdTargeted + 'a; // Provided method fn send_and_receive_one<'a, T>( &'a self, request: T ) -> Result<T::Response, SendError<SenderCouplet<P>>> where T: RequestWithResponse<P> + IdTargeted + 'a { ... } }
Expand description

This trait allows a consumer to use a trait instead of the concrete implementation of thread pool.\ Unfortunately the send_and_receive are not a precise match for corresponding function in crate::ThreadPool itself. This is because of the limitation of the trait return types (it has to return a boxed iterator)

Required Methods§

source

fn send_and_receive<'a, T>( &'a self, requests: impl Iterator<Item = T> + 'a ) -> Result<Box<dyn Iterator<Item = T::Response> + 'a>, SendError<SenderCouplet<P>>>
where T: RequestWithResponse<P> + IdTargeted + 'a,

This function sends a request to a worker thread and receives a response back

The request is received as a vec and the responses are received back in a vec

Provided Methods§

source

fn send_and_receive_one<'a, T>( &'a self, request: T ) -> Result<T::Response, SendError<SenderCouplet<P>>>
where T: RequestWithResponse<P> + IdTargeted + 'a,

a default convenience function for dealing with the case when there is specifically only one message to send and (therefore) only one response to receive

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<P> SenderAndReceiver<P> for SenderAndReceiverRawMock<P>

source§

impl<P> SenderAndReceiver<P> for ThreadPool<P>
where P: PoolItem,

An implementation of the [ThreadPoolSenderAndReceiver] trait for ThreadPool

source§

impl<P, T1> SenderAndReceiver<P> for SenderAndReceiverMock<P, T1>