Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swarm): introduce ToSwarm type alias #3273

Closed

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
1 participant