Skip to content

Conversation

@thomaseizinger
Copy link
Contributor

@thomaseizinger thomaseizinger commented Dec 21, 2022

Description

The NetworkBehaviourAction type is often clunky to name because it has several type parameters. Usually, those can all be inferred from the corresponding NetworkBehaviour. 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 called ToSwarm which is just a NetworkBehaviourAction with all parameters inferred from a NetworkBehaviour.

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 from NetworkBehaviourAction.

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

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@thomaseizinger
Copy link
Contributor Author

Too many merge conflicts, might pursue in the future.

@thomaseizinger thomaseizinger deleted the refactor-swarm/introduce-to-swarm-alias branch April 26, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

swarm: Rename NetworkBehaviourAction to ToSwarm

2 participants