Skip to content

Commit

Permalink
swarm/src/behaviour: Fix outdated comment on derive's out_event (#2318)
Browse files Browse the repository at this point in the history
The default behaviour changed with
#2214. This updates the doc
comment.

Initially raised in
#2290 (comment).
  • Loading branch information
mxinden committed Oct 30, 2021
1 parent 8ea60af commit 997cc9a
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions swarm/src/behaviour.rs
Expand Up @@ -39,27 +39,23 @@ type THandlerInEvent<THandler> =
///
/// Crate users can implement this trait by using the the `#[derive(NetworkBehaviour)]`
/// proc macro re-exported by the `libp2p` crate. The macro generates a delegating `trait`
/// implementation for the `struct`, which delegates method calls to all trait members.
/// implementation for the `struct`, which delegates method calls to all struct members.
///
/// Struct members that don't implement [`NetworkBehaviour`] must be annotated with `#[behaviour(ignore)]`.
///
/// By default the derive sets the [`NetworkBehaviour::OutEvent`] as `()` but this can be overridden
/// with `#[behaviour(out_event = "AnotherType")]`.
///
/// Struct members that don't implement [`NetworkBehaviour`] must be annotated with `#[behaviour(ignore)]`.
///
/// By default, events generated by the remaining members are delegated to [`NetworkBehaviourEventProcess`]
/// implementations. Those must be provided by the user on the type that [`NetworkBehaviour`] is
/// derived on.
/// When setting a custom `out_event` users have to implement [`From`] converting from each of the
/// event types generated by the struct members to the custom `out_event`.
///
/// Alternatively, users can specify `#[behaviour(event_process = false)]`. In this case, users
/// should provide a custom `out_event` and implement [`From`] for each of the event types generated
/// by the struct members.
/// Not processing events within the derived [`NetworkBehaviour`] will cause them to be emitted as
/// part of polling the swarm in [`SwarmEvent::Behaviour`](crate::SwarmEvent::Behaviour).
/// Alternatively, users can specify `#[behaviour(event_process = true)]`. Events generated by the
/// struct members are delegated to [`NetworkBehaviourEventProcess`] implementations. Those must be
/// provided by the user on the type that [`NetworkBehaviour`] is derived on.
///
/// Optionally one can provide a custom `poll` function through the `#[behaviour(poll_method = "poll")]`
/// attribute.
/// This function must have the same signature as the [`NetworkBehaviour#poll`] function and will
/// be called last within the generated [`NetworkBehaviour`] implementation.
/// Optionally one can provide a custom `poll` function through the `#[behaviour(poll_method =
/// "poll")]` attribute. This function must have the same signature as the [`NetworkBehaviour#poll`]
/// function and will be called last within the generated [`NetworkBehaviour`] implementation.
pub trait NetworkBehaviour: Send + 'static {
/// Handler for all the protocols the network behaviour supports.
type ProtocolsHandler: IntoProtocolsHandler;
Expand Down

0 comments on commit 997cc9a

Please sign in to comment.