pub struct RequestResponsesBehaviour { /* private fields */ }Expand description
Implementation of NetworkBehaviour that provides support for request-response protocols.
Implementations§
source§impl RequestResponsesBehaviour
impl RequestResponsesBehaviour
sourcepub fn new(
list: impl Iterator<Item = ProtocolConfig>,
peerset: PeersetHandle
) -> Result<Self, RegisterError>
pub fn new( list: impl Iterator<Item = ProtocolConfig>, peerset: PeersetHandle ) -> 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
)
pub fn send_request( &mut self, target: &PeerId, protocol_name: &str, request: Vec<u8>, pending_response: Sender<Result<Vec<u8>, RequestFailure>>, connect: IfDisconnected )
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 RequestResponsesBehaviour
impl NetworkBehaviour for RequestResponsesBehaviour
§type ConnectionHandler = MultiHandler<String, <RequestResponse<GenericCodec> as NetworkBehaviour>::ConnectionHandler>
type ConnectionHandler = MultiHandler<String, <RequestResponse<GenericCodec> as NetworkBehaviour>::ConnectionHandler>
Handler for all the protocols the network behaviour supports.
source§fn new_handler(&mut self) -> Self::ConnectionHandler
fn new_handler(&mut self) -> Self::ConnectionHandler
Creates a new [
ConnectionHandler] for a connection with a peer. Read moresource§fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr>
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr>
Addresses that this behaviour is aware of for this specific peer, and that may allow
reaching the peer. Read more
source§fn on_swarm_event(&mut self, event: FromSwarm<'_, Self::ConnectionHandler>)
fn on_swarm_event(&mut self, event: FromSwarm<'_, Self::ConnectionHandler>)
Informs the behaviour about an event from the
Swarm.source§fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection_id: ConnectionId,
(p_name, event): <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn on_connection_handler_event( &mut self, peer_id: PeerId, connection_id: ConnectionId, (p_name, event): <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent )
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<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>>
fn poll( &mut self, cx: &mut Context<'_>, params: &mut impl PollParameters ) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>>
Polls for things that swarm should do. Read more
§fn inject_connection_established(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
failed_addresses: Option<&Vec<Multiaddr, Global>>,
other_established: usize
)
fn inject_connection_established( &mut self, peer_id: &PeerId, connection_id: &ConnectionId, endpoint: &ConnectedPoint, failed_addresses: Option<&Vec<Multiaddr, Global>>, other_established: usize )
👎Deprecated since 0.40.2: Handle
FromSwarm::ConnectionEstablished in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Informs the behaviour about a newly established connection to a peer.
§fn inject_connection_closed(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize
)
fn inject_connection_closed( &mut self, peer_id: &PeerId, connection_id: &ConnectionId, endpoint: &ConnectedPoint, handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler, remaining_established: usize )
👎Deprecated since 0.40.2: Handle
FromSwarm::ConnectionClosed in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Informs the behaviour about a closed connection to a peer. Read more
§fn inject_address_change(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
old: &ConnectedPoint,
new: &ConnectedPoint
)
fn inject_address_change( &mut self, peer_id: &PeerId, connection_id: &ConnectionId, old: &ConnectedPoint, new: &ConnectedPoint )
👎Deprecated since 0.40.2: Handle
FromSwarm::AddressChange in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Informs the behaviour that the [
ConnectedPoint] of an existing connection has changed.§fn inject_event(
&mut self,
peer_id: PeerId,
connection: ConnectionId,
event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn inject_event( &mut self, peer_id: PeerId, connection: ConnectionId, event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent )
👎Deprecated since 0.40.2: Implement
NetworkBehaviour::on_connection_handler_event instead. The default implementation of this inject_* method delegates to it.Informs the behaviour about an event generated by the handler dedicated to the peer identified by
peer_id.
for the behaviour. Read more§fn inject_dial_failure(
&mut self,
peer_id: Option<PeerId>,
handler: Self::ConnectionHandler,
error: &DialError
)
fn inject_dial_failure( &mut self, peer_id: Option<PeerId>, handler: Self::ConnectionHandler, error: &DialError )
👎Deprecated since 0.40.2: Handle
InEvent::DialFailure in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that the dial to a known or unknown node failed.
§fn inject_listen_failure(
&mut self,
local_addr: &Multiaddr,
send_back_addr: &Multiaddr,
handler: Self::ConnectionHandler
)
fn inject_listen_failure( &mut self, local_addr: &Multiaddr, send_back_addr: &Multiaddr, handler: Self::ConnectionHandler )
👎Deprecated since 0.40.2: Handle
FromSwarm::ListenFailure in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that an error happened on an incoming connection during its
initial handshake. Read more
§fn inject_new_listener(&mut self, id: ListenerId)
fn inject_new_listener(&mut self, id: ListenerId)
👎Deprecated since 0.40.2: Handle
FromSwarm::NewListener in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that a new listener was created.
§fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
👎Deprecated since 0.40.2: Handle
FromSwarm::NewListenAddr in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that we have started listening on a new multiaddr.
§fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr)
👎Deprecated since 0.40.2: Handle
FromSwarm::ExpiredListenAddr in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that a multiaddr we were listening on has expired,
which means that we are no longer listening on it.
§fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn Error + 'static))
fn inject_listener_error(&mut self, id: ListenerId, err: &(dyn Error + 'static))
👎Deprecated since 0.40.2: Handle
FromSwarm::ListenerError in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.A listener experienced an error.
§fn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &Error>)
fn inject_listener_closed(&mut self, id: ListenerId, reason: Result<(), &Error>)
👎Deprecated since 0.40.2: Handle
FromSwarm::ListenerClosed in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.A listener closed.
§fn inject_new_external_addr(&mut self, addr: &Multiaddr)
fn inject_new_external_addr(&mut self, addr: &Multiaddr)
👎Deprecated since 0.40.2: Handle
FromSwarm::NewExternalAddr in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that we have discovered a new external address for us.
§fn inject_expired_external_addr(&mut self, addr: &Multiaddr)
fn inject_expired_external_addr(&mut self, addr: &Multiaddr)
👎Deprecated since 0.40.2: Handle
FromSwarm::ExpiredExternalAddr in NetworkBehaviour::on_swarm_event instead. The default implementation of this inject_* method delegates to it.Indicates to the behaviour that an external address was removed.
Auto Trait Implementations§
impl !RefUnwindSafe for RequestResponsesBehaviour
impl Send for RequestResponsesBehaviour
impl !Sync for RequestResponsesBehaviour
impl Unpin for RequestResponsesBehaviour
impl !UnwindSafe for RequestResponsesBehaviour
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T.