-
Notifications
You must be signed in to change notification settings - Fork 1
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
swarm/src/behaviour: Make NetworkBehaviourAction generic over TBehaviour #5
Conversation
Interesting that clippy flags |
How often do we use these From my own experience, I don't think I ever used these although implementations like the Instead of providing individual |
Considering libp2p#2191 as the status quo, we use them within I don't have a strong opinion here. As of today, I am in favor of keeping them, despite the complexity it adds to |
What do you think of doing the following instead: enum NetworkBehaviourAction<TBehaviour> {
GenerateEvent(TBehaviour::OutEvent),
// ...
}
impl<TBehaviour> NetworkBehaviourAction<TBehaviour> {
// (signature not complete)
fn map<TOther>(self, map_event: impl Fn(TBehaviour::OutEvent) -> TOther::OutEvent, map_handler: impl Fn) -> NetworkBehaviourAction<TOther> {
// ...
}
} Would this work for all of our usecases? |
Thanks for following up here. Off the top of my head, yes, the Still, the issue of I will explore this option next week. |
That was the idea! If we are referring to associated types, it cannot possible be flagged as unused! The downside is that we need to put a trait-bound on the type declaration itself. I consider that an anti-pattern because it makes the trait-bound creep through all usages of the type. That being said, the type is probably not named much outside of rust-libp2p. |
Follow up on libp2p#2191 (comment).
//CC @thomaseizinger