pub struct RequestResponseFactoryBehaviour { /* private fields */ }
Expand description
Implementation of NetworkBehaviour
that provides support for multiple request-response
protocols.
Implementations§
source§impl RequestResponseFactoryBehaviour
impl RequestResponseFactoryBehaviour
sourcepub fn new(
list: impl IntoIterator<Item = Box<dyn RequestHandler>>,
) -> Result<Self, RegisterError>
pub fn new( list: impl IntoIterator<Item = Box<dyn RequestHandler>>, ) -> Result<Self, RegisterError>
Creates a new behaviour. Must be passed a list of supported protocols. Returns an error if the same protocol is passed twice.
sourcepub fn send_request(
&mut self,
target: &PeerId,
protocol_name: &str,
request: Vec<u8>,
pending_response: Sender<Result<Vec<u8>, RequestFailure>>,
connect: IfDisconnected,
addresses: Vec<Multiaddr>,
)
pub fn send_request( &mut self, target: &PeerId, protocol_name: &str, request: Vec<u8>, pending_response: Sender<Result<Vec<u8>, RequestFailure>>, connect: IfDisconnected, addresses: Vec<Multiaddr>, )
Initiates sending a request.
If there is no established connection to the target peer, the behavior is determined by the
choice of connect
.
An error is returned if the protocol doesn’t match one that has been registered.
Trait Implementations§
source§impl NetworkBehaviour for RequestResponseFactoryBehaviour
impl NetworkBehaviour for RequestResponseFactoryBehaviour
source§fn on_swarm_event(&mut self, event: FromSwarm<'_>)
fn on_swarm_event(&mut self, event: FromSwarm<'_>)
Informs the behaviour about an event from the Swarm
.
source§type ConnectionHandler = MultiHandler<String, <Behaviour<GenericCodec> as NetworkBehaviour>::ConnectionHandler>
type ConnectionHandler = MultiHandler<String, <Behaviour<GenericCodec> as NetworkBehaviour>::ConnectionHandler>
Handler for all the protocols the network behaviour supports.
source§type ToSwarm = Event
type ToSwarm = Event
Event generated by the
NetworkBehaviour
and that the swarm will report back.source§fn handle_established_inbound_connection(
&mut self,
connection_id: ConnectionId,
peer: PeerId,
local_addr: &Multiaddr,
remote_addr: &Multiaddr,
) -> Result<Self::ConnectionHandler, ConnectionDenied>
fn handle_established_inbound_connection( &mut self, connection_id: ConnectionId, peer: PeerId, local_addr: &Multiaddr, remote_addr: &Multiaddr, ) -> Result<Self::ConnectionHandler, ConnectionDenied>
Callback that is invoked for every established inbound connection. Read more
source§fn handle_established_outbound_connection(
&mut self,
connection_id: ConnectionId,
peer: PeerId,
addr: &Multiaddr,
role_override: Endpoint,
port_use: PortUse,
) -> Result<Self::ConnectionHandler, ConnectionDenied>
fn handle_established_outbound_connection( &mut self, connection_id: ConnectionId, peer: PeerId, addr: &Multiaddr, role_override: Endpoint, port_use: PortUse, ) -> Result<Self::ConnectionHandler, ConnectionDenied>
Callback that is invoked for every established outbound connection. Read more
source§fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection: ConnectionId,
event: THandlerOutEvent<Self>,
)
fn on_connection_handler_event( &mut self, peer_id: PeerId, connection: ConnectionId, event: THandlerOutEvent<Self>, )
Informs the behaviour about an event generated by the [
ConnectionHandler
]
dedicated to the peer identified by peer_id
. for the behaviour. Read moresource§fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>>
fn poll( &mut self, cx: &mut Context<'_>, ) -> Poll<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>>
Polls for things that swarm should do. Read more
§fn handle_pending_inbound_connection(
&mut self,
_connection_id: ConnectionId,
_local_addr: &Multiaddr,
_remote_addr: &Multiaddr,
) -> Result<(), ConnectionDenied>
fn handle_pending_inbound_connection( &mut self, _connection_id: ConnectionId, _local_addr: &Multiaddr, _remote_addr: &Multiaddr, ) -> Result<(), ConnectionDenied>
Callback that is invoked for every new inbound connection. Read more
Auto Trait Implementations§
impl !Freeze for RequestResponseFactoryBehaviour
impl !RefUnwindSafe for RequestResponseFactoryBehaviour
impl Send for RequestResponseFactoryBehaviour
impl !Sync for RequestResponseFactoryBehaviour
impl Unpin for RequestResponseFactoryBehaviour
impl !UnwindSafe for RequestResponseFactoryBehaviour
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more