Trait brw::broker::Broker [−][src]
pub trait Broker: Sized {
type Item: Send + 'static;
type WriterItem: Send + 'static;
type Ok: Send;
type Error: Error + Send;
fn op<'life0, 'life1, 'async_trait, W>(
&'life0 mut self,
ctx: &'life1 Arc<Context<Self::Item>>,
item: Self::Item,
writer: W
) -> Pin<Box<dyn Future<Output = Running<Result<Self::Ok, Self::Error>, Option<Self::Error>>> + Send + 'async_trait>>
where
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
W: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn handle_result<'async_trait>(
res: Result<Self::Ok, Self::Error>
) -> Pin<Box<dyn Future<Output = Running<(), Option<Self::Error>>> + Send + 'async_trait>>
where
Self: Send + 'async_trait,
{ ... }
fn broker_loop<'async_trait, S, W, RH, WH>(
self,
items: S,
writer: W,
ctx: Arc<Context<Self::Item>>,
stop: Receiver<()>,
reader_handle: RH,
writer_handle: WH
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where
S: Stream<Item = Self::Item> + Send + Unpin,
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
RH: Future + Send,
WH: Future + Send,
S: 'async_trait,
W: 'async_trait,
RH: 'async_trait,
WH: 'async_trait,
Self: Send + 'async_trait,
{ ... }
}
Expand description
Broker of the broker-reader-writer pattern
Associated Types
type WriterItem: Send + 'static
type WriterItem: Send + 'static
Item sent to the writer
Required methods
fn op<'life0, 'life1, 'async_trait, W>(
&'life0 mut self,
ctx: &'life1 Arc<Context<Self::Item>>,
item: Self::Item,
writer: W
) -> Pin<Box<dyn Future<Output = Running<Result<Self::Ok, Self::Error>, Option<Self::Error>>> + Send + 'async_trait>> where
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
W: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn op<'life0, 'life1, 'async_trait, W>(
&'life0 mut self,
ctx: &'life1 Arc<Context<Self::Item>>,
item: Self::Item,
writer: W
) -> Pin<Box<dyn Future<Output = Running<Result<Self::Ok, Self::Error>, Option<Self::Error>>> + Send + 'async_trait>> where
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
W: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
The operation to perform
Provided methods
Handles the result of each op
Returns a None
to stop the whole loop
fn broker_loop<'async_trait, S, W, RH, WH>(
self,
items: S,
writer: W,
ctx: Arc<Context<Self::Item>>,
stop: Receiver<()>,
reader_handle: RH,
writer_handle: WH
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
S: Stream<Item = Self::Item> + Send + Unpin,
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
RH: Future + Send,
WH: Future + Send,
S: 'async_trait,
W: 'async_trait,
RH: 'async_trait,
WH: 'async_trait,
Self: Send + 'async_trait,
fn broker_loop<'async_trait, S, W, RH, WH>(
self,
items: S,
writer: W,
ctx: Arc<Context<Self::Item>>,
stop: Receiver<()>,
reader_handle: RH,
writer_handle: WH
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
S: Stream<Item = Self::Item> + Send + Unpin,
W: Sink<Self::WriterItem, Error = SendError<Self::WriterItem>> + Send + Unpin,
RH: Future + Send,
WH: Future + Send,
S: 'async_trait,
W: 'async_trait,
RH: 'async_trait,
WH: 'async_trait,
Self: Send + 'async_trait,
Runs the operation in a loop