Struct network::peer_manager::PeerManagerRequestSender
source · pub struct PeerManagerRequestSender { /* private fields */ }
Expand description
Convenience wrapper which makes it easy to issue communication requests and await the responses from PeerManager.
Implementations§
source§impl PeerManagerRequestSender
impl PeerManagerRequestSender
sourcepub fn new(inner: Sender<(PeerId, ProtocolId), PeerManagerRequest>) -> Self
pub fn new(inner: Sender<(PeerId, ProtocolId), PeerManagerRequest>) -> Self
Construct a new PeerManagerRequestSender with a raw channel::Sender
sourcepub fn send_to(
&mut self,
peer_id: PeerId,
protocol_id: ProtocolId,
mdata: Bytes
) -> Result<(), PeerManagerError>
pub fn send_to( &mut self, peer_id: PeerId, protocol_id: ProtocolId, mdata: Bytes ) -> Result<(), PeerManagerError>
Send a fire-and-forget direct-send message to remote peer.
The function returns when the message has been enqueued on the network actor’s event queue. It therefore makes no reliable delivery guarantees. An error is returned if the event queue is unexpectedly shutdown.
sourcepub fn send_to_many(
&mut self,
recipients: impl Iterator<Item = PeerId>,
protocol_id: ProtocolId,
mdata: Bytes
) -> Result<(), PeerManagerError>
pub fn send_to_many( &mut self, recipients: impl Iterator<Item = PeerId>, protocol_id: ProtocolId, mdata: Bytes ) -> Result<(), PeerManagerError>
Send the same message to many recipients using the direct-send protocol.
This method is an optimization so that we can avoid serializing and
copying the same message many times when we want to sent a single message
to many peers. Note that the Bytes
the messages is serialized into is a
ref-counted byte buffer, so we can avoid excess copies as all direct-sends
will share the same underlying byte buffer.
The function returns when all send requests have been enqueued on the network actor’s event queue. It therefore makes no reliable delivery guarantees. An error is returned if the event queue is unexpectedly shutdown.
Trait Implementations§
source§impl Clone for PeerManagerRequestSender
impl Clone for PeerManagerRequestSender
source§fn clone(&self) -> PeerManagerRequestSender
fn clone(&self) -> PeerManagerRequestSender
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more