-
Notifications
You must be signed in to change notification settings - Fork 173
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
move Publisher.write method into trait #736
move Publisher.write method into trait #736
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we also plan to implement this trait for other types, I'm against this PR as a concept: it's a breaking change, makes finding this capability of the Publisher more complex, makes the doc worse by splitting it, and doesn't bring any code reuse benefits.
If we insist that we want to do this, then this PR's code is acceptable, but like I said, I don't think we want to do this.
The very reason for the |
To me, separating it doesn't make the API any simpler, so I find the cost of an API break to high. Splitting a method off into a trait makes sense when there may be multiple implementors, or when adding methods to a foreign type. I don't think it's helpful to "hide" methods, especially given that this one's semantic is far from complex. My reasoning is that this has no benefits (adding indirections in the doc is not one IMO), so there's no reason to break this API. A much greater improvement IMO would be to change the doc to something like:
This would make the use-case and alternatives much easier to understand than sweeping the API under the rug. |
Again, my point is that method does NOT exist and it makes the API asymmetrical. This an API whose sole reason to exist is for some Rust ergonomics. I tend to disagree with Splitting a method off into a trait makes sense when there may be multiple implementors, it can also be use to explicitly group a set of methods under a given What we want to convey here is: this is an API specific to Rust, not a generic Zenoh Publisher. Another way to see it, is that this API should implement something like |
I'd support @p-avital. I'm also kind of against to the idea of using traits as a way to separate API to "first-class" and "second-class" elements. |
Write accepts a |
Agree with @Mallets. The |
move Publisher.write method into HasWriteWithSampleKind trait (closes #731 )