feat(swarm): introduce ToSwarm
type alias
#3242
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 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.
I think we should not merge this PR until that is sorted.
Depends-On: #3239 to remove the build failures in
libp2p-kad
.Depends-On: #3241
I've tagged this as resolving #3123 but didn't straight away deprecate
NetworkBehaviourAction
because we still use it in gossipsub to implement some optimization viaArc
. Once/if #3243 is merged, the next step is to remove the trait bounds fromNetworkBehaviourAction
.Links to any relevant issues
Open Questions
Change checklist