pub trait Publisher<T> {
// Required methods
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A non-locking replacement for Sink.
Interactions with a Sink generally require exclusive
mutable access to the underlying sink, which is problematic when working in
a highly concurrent system. While implementations of
Sink, like
futures::channel::mpsc::Sender, are
generally cloneable, the Sink trait itself does not
require any such guarantees, which means that code that simply relies on
Sink may not make any assumptions about the ability to
clone the underlying Sink. As such, we provide a trait
that is functionally equivalent to Sink, but does not
require exclusive mutable access to publish messages.
Required Methods§
Sourcefn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Publish a message.
The implementation should be take care of serializing the payload before publishing.