pub trait MessageSink: Send + Sync {
// Required methods
fn send_sync_notification(&self, notification: Vec<u8>);
fn send_async_notification<'life0, 'async_trait>(
&'life0 self,
notification: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Message sink for peers.
If protocol cannot use NotificationService
to send notifications to peers and requires,
e.g., notifications to be sent in another task, the protocol may acquire a MessageSink
object for each peer by calling NotificationService::message_sink()
. Calling this
function returns an object which allows the protocol to send notifications to the remote peer.
Use of this API is discouraged as it’s not as performant as sending notifications through
NotificationService
due to synchronization required to keep the underlying notification
sink up to date with possible sink replacement events.
Required Methods§
Sourcefn send_sync_notification(&self, notification: Vec<u8>)
fn send_sync_notification(&self, notification: Vec<u8>)
Send synchronous notification
to the peer associated with this MessageSink
.
Sourcefn send_async_notification<'life0, 'async_trait>(
&'life0 self,
notification: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_async_notification<'life0, 'async_trait>(
&'life0 self,
notification: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send an asynchronous notification
to to the peer associated with this MessageSink
,
allowing sender to exercise backpressure.
Returns an error if the peer does not exist.
Implementations on Foreign Types§
Source§impl MessageSink for Arc<Mutex<(NotificationsSink, ProtocolName)>>
impl MessageSink for Arc<Mutex<(NotificationsSink, ProtocolName)>>
Source§fn send_sync_notification(&self, notification: Vec<u8>)
fn send_sync_notification(&self, notification: Vec<u8>)
Send synchronous notification
to the peer associated with this MessageSink
.
Source§fn send_async_notification<'life0, 'async_trait>(
&'life0 self,
notification: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_async_notification<'life0, 'async_trait>(
&'life0 self,
notification: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send an asynchronous notification
to the peer associated with this MessageSink
,
allowing sender to exercise backpressure.
Returns an error if the peer does not exist.