-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Suggestion: replace all the NetworkBehaviour::inject_* methods with a single one #1522
Comments
One difference would be that adding a new method with a default implementation can be a minor change, thus requiring only a minor semver increment, whereas a new enum constructor is always a major change unless we annotate the enum with |
I like the idea in general and using |
Only concerning As a downstream crate owner I would very much appreciate if my compiler can tell me that there was a new event added in an upstream crate that I depend on. Marking the enum as Is the trade-off (improving the new-feature path) worth the lost safety? |
I did not argue in favour of adding |
The problem is that I can imagine adding new events that can reasonably be ignored by users, but I can also imagine adding new events that the user should not ignore. For example (assuming #1519 is merged), we have this If later for some reason we add a new event, separate from |
On its own this would suggest to keep the current approach instead of switching to an enum. The original motivation for the change was:
Could you expand on this maybe? |
Closing in favor of #2832. |
After #1515, the
SwarmEvent
is very redundant with the methods in theNetworkBehaviour
.Instead of having several
inject_*
methods, one idea would be to have a singleinject_event
method (it could be namedon_event
or something else as well) that accepts an enum as parameter.This would considerably simplify writing implementations of
NetworkBehaviour
that are built on top of anotherNetworkBehaviour
.cc #1021 which is slightly related
The text was updated successfully, but these errors were encountered: