feat(swarm): introduce ToSwarm
type alias
#3273
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
NetworkBehaviourAction
type is often clunky to name because it has several type parameters. Usually, those can all be inferred from the correspondingNetworkBehaviour
. However, that would require us to add bounds to the type definition which generally not a good idea because those bounds creep easily into upper layers where you don't want them.This PR instead adds a type alias for
NetworkBehaviourAction
calledToSwarm
which is just aNetworkBehaviourAction
with all parameters inferred from aNetworkBehaviour
.Resolves #3123.
Notes
At the moment, this is just an experiment.
This might be easier after we merge #3254 where we remove the
THandler
type parameter fromNetworkBehaviourAction
.At the moment, this only compiles by adding type annotations everywhere which is kind of unacceptable. I opened an issue on rust-lang/rust for that: rust-lang/rust#105680.
Depends-On: #3239 to remove the build failures in
libp2p-kad
.Links to any relevant issues
Open Questions
Change checklist