Trait rust_ipfs::NetworkBehaviour
pub trait NetworkBehaviour: 'static {
type ConnectionHandler: IntoConnectionHandler;
type OutEvent: Send + 'static;
Show 18 methods
fn new_handler(&mut self) -> Self::ConnectionHandler;
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler, <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>;
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr, Global> ⓘ { ... }
fn on_swarm_event(&mut self, _event: FromSwarm<'_, Self::ConnectionHandler>) { ... }
fn on_connection_handler_event(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
) { ... }
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_closed(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
handler: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize
) { ... }
fn inject_address_change(
&mut self,
peer_id: &PeerId,
connection_id: &ConnectionId,
old: &ConnectedPoint,
new: &ConnectedPoint
) { ... }
fn inject_event(
&mut self,
peer_id: PeerId,
connection: ConnectionId,
event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
) { ... }
fn inject_dial_failure(
&mut self,
peer_id: Option<PeerId>,
handler: Self::ConnectionHandler,
error: &DialError
) { ... }
fn inject_listen_failure(
&mut self,
local_addr: &Multiaddr,
send_back_addr: &Multiaddr,
handler: Self::ConnectionHandler
) { ... }
fn inject_new_listener(&mut self, id: ListenerId) { ... }
fn inject_new_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) { ... }
fn inject_expired_listen_addr(&mut self, id: ListenerId, addr: &Multiaddr) { ... }
fn inject_listener_error(
&mut self,
id: ListenerId,
err: &(dyn Error + 'static)
) { ... }
fn inject_listener_closed(
&mut self,
id: ListenerId,
reason: Result<(), &Error>
) { ... }
fn inject_new_external_addr(&mut self, addr: &Multiaddr) { ... }
fn inject_expired_external_addr(&mut self, addr: &Multiaddr) { ... }
}
Expand description
A NetworkBehaviour
defines the behaviour of the local node on the network.
In contrast to Transport
which defines how to send bytes on the
network, NetworkBehaviour
defines what bytes to send and to whom.
Each protocol (e.g. libp2p-ping
, libp2p-identify
or libp2p-kad
) implements
NetworkBehaviour
. Multiple implementations of NetworkBehaviour
can be composed into a
hierarchy of NetworkBehaviour
s where parent implementations delegate to child
implementations. Finally the root of the NetworkBehaviour
hierarchy is passed to
Swarm
where it can then control the behaviour of the local node on a libp2p
network.
Hierarchy of NetworkBehaviour
To compose multiple NetworkBehaviour
implementations into a single NetworkBehaviour
implementation, potentially building a multi-level hierarchy of NetworkBehaviour
s, one can
use one of the NetworkBehaviour
combinators, and/or use the NetworkBehaviour
derive
macro.
Combinators
NetworkBehaviour
combinators wrap one or more NetworkBehaviour
implementations and
implement NetworkBehaviour
themselves. Example is the
Toggle
NetworkBehaviour
.
let my_behaviour = dummy::Behaviour;
let my_toggled_behaviour = Toggle::from(Some(my_behaviour));
Custom NetworkBehaviour
with the Derive Macro
One can derive NetworkBehaviour
for a custom struct
via the #[derive(NetworkBehaviour)]
proc macro re-exported by the libp2p
crate. The macro generates a delegating trait
implementation for the custom struct
. Each NetworkBehaviour
trait method is simply
delegated to each struct
member in the order the struct
is defined. For example for
NetworkBehaviour::poll
it will first poll the first struct
member until it returns
Poll::Pending
before moving on to later members. For NetworkBehaviour::addresses_of_peer
it will delegate to each struct
member and return a concatenated array of all addresses
returned by the struct members.
Events (NetworkBehaviour::OutEvent
) returned by each struct
member are wrapped in a new
enum
event, with an enum
variant for each struct
member. Users can define this event
enum
themselves and provide the name to the derive macro via #[behaviour(out_event = "MyCustomOutEvent")]
. If the user does not specify an out_event
, the derive macro generates
the event definition itself, naming it <STRUCT_NAME>Event
.
The aforementioned conversion of each of the event types generated by the struct members to the
custom out_event
is handled by From
implementations which the user needs to define in
addition to the event enum
itself.
#[derive(NetworkBehaviour)]
#[behaviour(out_event = "Event")]
struct MyBehaviour {
identify: identify::Behaviour,
ping: ping::Behaviour,
}
enum Event {
Identify(identify::Event),
Ping(ping::Event),
}
impl From<identify::Event> for Event {
fn from(event: identify::Event) -> Self {
Self::Identify(event)
}
}
impl From<ping::Event> for Event {
fn from(event: ping::Event) -> Self {
Self::Ping(event)
}
}
Required Associated Types§
type ConnectionHandler: IntoConnectionHandler
type ConnectionHandler: IntoConnectionHandler
Handler for all the protocols the network behaviour supports.
Required Methods§
fn new_handler(&mut self) -> Self::ConnectionHandler
fn new_handler(&mut self) -> Self::ConnectionHandler
Creates a new [ConnectionHandler
] for a connection with a peer.
Every time an incoming connection is opened, and every time another NetworkBehaviour
emitted a dial request, this method is called.
The returned object is a handler for that specific connection, and will be moved to a background task dedicated to that connection.
The network behaviour (ie. the implementation of this trait) and the handlers it has spawned
(ie. the objects returned by new_handler
) can communicate by passing messages. Messages
sent from the handler to the behaviour are injected with NetworkBehaviour::inject_event
,
and the behaviour can send a message to the handler by making NetworkBehaviour::poll
return [NetworkBehaviourAction::NotifyHandler
].
Note that the handler is returned to the NetworkBehaviour
on connection failure and
connection closing.
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler, <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler, <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
Polls for things that swarm should do.
This API mimics the API of the Stream
trait. The method may register the current task in
order to wake it up at a later point in time.
Provided Methods§
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr, Global> ⓘ
Addresses that this behaviour is aware of for this specific peer, and that may allow reaching the peer.
The addresses will be tried in the order returned by this function, which means that they should be ordered by decreasing likelihood of reachability. In other words, the first address should be the most likely to be reachable.
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
.
fn on_connection_handler_event(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn on_connection_handler_event(
&mut self,
_peer_id: PeerId,
_connection_id: ConnectionId,
_event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
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
)
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
)
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.
A call to this method is always paired with an earlier call to
NetworkBehaviour::inject_connection_established
with the same peer ID, connection ID and endpoint.
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
)
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
)
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.
The peer_id
is guaranteed to be in a connected state. In other words,
NetworkBehaviour::inject_connection_established
has previously been called with this PeerId
.
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
)
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
)
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.
This can include, for example, an error during the handshake of the encryption layer, or the connection unexpectedly closed.
fn inject_new_listener(&mut self, id: ListenerId)
fn inject_new_listener(&mut self, id: ListenerId)
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)
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)
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))
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>)
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)
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)
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.
Implementations on Foreign Types§
§impl NetworkBehaviour for Behaviour
impl NetworkBehaviour for Behaviour
type ConnectionHandler = <RequestResponse<AutoNatCodec> as NetworkBehaviour>::ConnectionHandler
type OutEvent = Event
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Behaviour as NetworkBehaviour>::OutEvent, <Behaviour as NetworkBehaviour>::ConnectionHandler, <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn new_handler(&mut self) -> <Behaviour as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Behaviour as NetworkBehaviour>::ConnectionHandler>
)
fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection_id: ConnectionId,
event: <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
§impl<TCodec> NetworkBehaviour for RequestResponse<TCodec>where
TCodec: RequestResponseCodec + Send + Clone + 'static,
impl<TCodec> NetworkBehaviour for RequestResponse<TCodec>where
TCodec: RequestResponseCodec + Send + Clone + 'static,
type ConnectionHandler = RequestResponseHandler<TCodec>
type OutEvent = RequestResponseEvent<<TCodec as RequestResponseCodec>::Request, <TCodec as RequestResponseCodec>::Response, <TCodec as RequestResponseCodec>::Response>
fn new_handler(
&mut self
) -> <RequestResponse<TCodec> as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <RequestResponse<TCodec> as NetworkBehaviour>::ConnectionHandler>
)
fn on_connection_handler_event(
&mut self,
peer: PeerId,
connection: ConnectionId,
event: <<<RequestResponse<TCodec> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn poll(
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<RequestResponse<TCodec> as NetworkBehaviour>::OutEvent, <RequestResponse<TCodec> as NetworkBehaviour>::ConnectionHandler, <<<RequestResponse<TCodec> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
§impl<L, R> NetworkBehaviour for Either<L, R>where
L: NetworkBehaviour,
R: NetworkBehaviour,
impl<L, R> NetworkBehaviour for Either<L, R>where
L: NetworkBehaviour,
R: NetworkBehaviour,
Implementation of NetworkBehaviour
that can be either of two implementations.
type ConnectionHandler = IntoEitherHandler<<L as NetworkBehaviour>::ConnectionHandler, <R as NetworkBehaviour>::ConnectionHandler>
type OutEvent = Either<<L as NetworkBehaviour>::OutEvent, <R as NetworkBehaviour>::OutEvent>
fn new_handler(
&mut self
) -> <Either<L, R> as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Either<L, R> as NetworkBehaviour>::ConnectionHandler>
)
fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection_id: ConnectionId,
event: <<<Either<L, R> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Either<L, R> as NetworkBehaviour>::OutEvent, <Either<L, R> as NetworkBehaviour>::ConnectionHandler, <<<Either<L, R> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
§impl NetworkBehaviour for Behaviour
impl NetworkBehaviour for Behaviour
type ConnectionHandler = Prototype
type OutEvent = Event
fn new_handler(&mut self) -> <Behaviour as NetworkBehaviour>::ConnectionHandler
fn on_connection_handler_event(
&mut self,
event_source: PeerId,
connection: ConnectionId,
handler_event: <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn poll(
&mut self,
_cx: &mut Context<'_>,
poll_parameters: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Behaviour as NetworkBehaviour>::OutEvent, <Behaviour as NetworkBehaviour>::ConnectionHandler, <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Behaviour as NetworkBehaviour>::ConnectionHandler>
)
§impl<C, F> NetworkBehaviour for Gossipsub<C, F>where
C: Send + 'static + DataTransform,
F: Send + 'static + TopicSubscriptionFilter,
impl<C, F> NetworkBehaviour for Gossipsub<C, F>where
C: Send + 'static + DataTransform,
F: Send + 'static + TopicSubscriptionFilter,
type ConnectionHandler = GossipsubHandler
type OutEvent = GossipsubEvent
fn new_handler(
&mut self
) -> <Gossipsub<C, F> as NetworkBehaviour>::ConnectionHandler
fn on_connection_handler_event(
&mut self,
propagation_source: PeerId,
_connection_id: ConnectionId,
handler_event: <<<Gossipsub<C, F> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn poll(
&mut self,
cx: &mut Context<'_>,
_: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Gossipsub<C, F> as NetworkBehaviour>::OutEvent, <Gossipsub<C, F> as NetworkBehaviour>::ConnectionHandler, <<<Gossipsub<C, F> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Gossipsub<C, F> as NetworkBehaviour>::ConnectionHandler>
)
§impl NetworkBehaviour for Behaviour
impl NetworkBehaviour for Behaviour
type ConnectionHandler = Proto
type OutEvent = Event
fn new_handler(&mut self) -> <Behaviour as NetworkBehaviour>::ConnectionHandler
fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
connection: ConnectionId,
event: <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent
)
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Behaviour as NetworkBehaviour>::OutEvent, <Behaviour as NetworkBehaviour>::ConnectionHandler, <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn addresses_of_peer(&mut self, peer: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Behaviour as NetworkBehaviour>::ConnectionHandler>
)
§impl<TStore> NetworkBehaviour for Kademlia<TStore>where
TStore: for<'a> RecordStore<'a> + Send + 'static,
impl<TStore> NetworkBehaviour for Kademlia<TStore>where
TStore: for<'a> RecordStore<'a> + Send + 'static,
type ConnectionHandler = KademliaHandlerProto<QueryId>
type OutEvent = KademliaEvent
fn new_handler(
&mut self
) -> <Kademlia<TStore> as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_connection_handler_event(
&mut self,
source: PeerId,
connection: ConnectionId,
event: KademliaHandlerEvent<QueryId>
)
fn poll(
&mut self,
cx: &mut Context<'_>,
parameters: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Kademlia<TStore> as NetworkBehaviour>::OutEvent, <Kademlia<TStore> as NetworkBehaviour>::ConnectionHandler, <<<Kademlia<TStore> as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Kademlia<TStore> as NetworkBehaviour>::ConnectionHandler>
)
§impl<P> NetworkBehaviour for Behaviour<P>where
P: Provider,
impl<P> NetworkBehaviour for Behaviour<P>where
P: Provider,
type ConnectionHandler = ConnectionHandler
type OutEvent = Event
fn new_handler(
&mut self
) -> <Behaviour<P> as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec<Multiaddr, Global> ⓘ
fn on_connection_handler_event(
&mut self,
_: PeerId,
_: ConnectionId,
ev: <<Behaviour<P> as NetworkBehaviour>::ConnectionHandler as ConnectionHandler>::OutEvent
)
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Behaviour<P> as NetworkBehaviour>::ConnectionHandler>
)
fn poll(
&mut self,
cx: &mut Context<'_>,
params: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Behaviour<P> as NetworkBehaviour>::OutEvent, ConnectionHandler, <<ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
§impl NetworkBehaviour for Behaviour
impl NetworkBehaviour for Behaviour
type ConnectionHandler = Handler
type OutEvent = Event
fn new_handler(&mut self) -> <Behaviour as NetworkBehaviour>::ConnectionHandler
fn on_connection_handler_event(
&mut self,
peer: PeerId,
_: ConnectionId,
result: Result<Success, Failure>
)
fn poll(
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Behaviour as NetworkBehaviour>::OutEvent, <Behaviour as NetworkBehaviour>::ConnectionHandler, <<<Behaviour as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Behaviour as NetworkBehaviour>::ConnectionHandler>
)
§impl NetworkBehaviour for Client
impl NetworkBehaviour for Client
type ConnectionHandler = Prototype
type OutEvent = Event
fn new_handler(&mut self) -> <Client as NetworkBehaviour>::ConnectionHandler
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Client as NetworkBehaviour>::ConnectionHandler>
)
fn on_connection_handler_event(
&mut self,
event_source: PeerId,
_connection: ConnectionId,
handler_event: Either<Event, Void>
)
fn poll(
&mut self,
cx: &mut Context<'_>,
_poll_parameters: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Client as NetworkBehaviour>::OutEvent, <Client as NetworkBehaviour>::ConnectionHandler, <<<Client as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
§impl NetworkBehaviour for Relay
impl NetworkBehaviour for Relay
type ConnectionHandler = Prototype
type OutEvent = Event
fn new_handler(&mut self) -> <Relay as NetworkBehaviour>::ConnectionHandler
fn on_swarm_event(
&mut self,
event: FromSwarm<'_, <Relay as NetworkBehaviour>::ConnectionHandler>
)
fn on_connection_handler_event(
&mut self,
event_source: PeerId,
connection: ConnectionId,
event: Either<Event, Void>
)
fn poll(
&mut self,
_cx: &mut Context<'_>,
poll_parameters: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Relay as NetworkBehaviour>::OutEvent, <Relay as NetworkBehaviour>::ConnectionHandler, <<<Relay as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::InEvent>>
source§impl NetworkBehaviour for Bitswap
impl NetworkBehaviour for Bitswap
type ConnectionHandler = OneShotHandler<BitswapConfig, Message, MessageWrapper>
type OutEvent = BitswapEvent
fn new_handler(&mut self) -> <Bitswap as NetworkBehaviour>::ConnectionHandler
fn addresses_of_peer(&mut self, _peer_id: &PeerId) -> Vec<Multiaddr, Global> ⓘ
source§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
)
FromSwarm::ConnectionEstablished
in NetworkBehaviour::on_swarm_event
instead. The default implementation of this inject_*
method delegates to it.source§fn inject_connection_closed(
&mut self,
peer_id: &PeerId,
_connection_id: &ConnectionId,
_endpoint: &ConnectedPoint,
_handler: <Bitswap as NetworkBehaviour>::ConnectionHandler,
_remaining_established: usize
)
fn inject_connection_closed(
&mut self,
peer_id: &PeerId,
_connection_id: &ConnectionId,
_endpoint: &ConnectedPoint,
_handler: <Bitswap as NetworkBehaviour>::ConnectionHandler,
_remaining_established: usize
)
FromSwarm::ConnectionClosed
in NetworkBehaviour::on_swarm_event
instead. The default implementation of this inject_*
method delegates to it.source§fn inject_event(
&mut self,
source: PeerId,
_connection: ConnectionId,
message: MessageWrapper
)
fn inject_event(
&mut self,
source: PeerId,
_connection: ConnectionId,
message: MessageWrapper
)
NetworkBehaviour::on_connection_handler_event
instead. The default implementation of this inject_*
method delegates to it.