swarm/src/protocols_handler: Document alternative to Event::Close (#2470)

There are 3 ways to close a connection:

1. `ProtocolsHandlerEvent::Close`
2. `KeepAlive::No` via `ProtocolsHandler::connection_keep_alive`
3. `NetworkBehaviourAction::CloseConnection`

This commit references (2) as an alternative to (1) in the documentation
of (1).
This commit is contained in:
Max Inden
2022-02-02 21:54:06 +01:00
committed by GitHub
parent ea180aa3a8
commit fbdd208da6

View File

@ -318,6 +318,13 @@ pub enum ProtocolsHandlerEvent<TConnectionUpgrade, TOutboundOpenInfo, TCustom, T
},
/// Close the connection for the given reason.
///
/// Note this will affect all [`ProtocolsHandler`]s handling this
/// connection, in other words it will close the connection for all
/// [`ProtocolsHandler`]s. To signal that one has no more need for the
/// connection, while allowing other [`ProtocolsHandler`]s to continue using
/// the connection, return [`KeepAlive::No`] in
/// [`ProtocolsHandler::connection_keep_alive`].
Close(TErr),
/// Other event.