-
Notifications
You must be signed in to change notification settings - Fork 75
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
[refactor] config: Use dedicated functions to set options #153
Conversation
9b01c64
to
a07fde4
Compare
With public members in the config structs the public API breaks each time we're adding new options as the users MUST or MUST NOT add ".. Default::default()" depending on whether they're setting all options or not. So adding new options breaks for those users who use all options. This change hides the members from the users and replaces access by dedicated setter functions for each option so adding new options does not break API in the future. (This change obviously is an API break in itself.) Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
a07fde4
to
20bb5fa
Compare
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.
I really really like this change and how it's used from the user interface 🚀
Only one ergonomic comment
/// Enables TCP keepalive settings on the socket. | ||
pub keepalive: Option<TcpKeepalive>, | ||
pub fn with_keepalive(mut self, keepalive: TcpKeepalive) -> Self { |
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.
I would reexport TcpKeepalive
type to avoid the user creating a dependency of socket2
only for its usage. Something like:
pub use socket2::TcpKeepalive;
in the top of the file.
Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
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.
LGTM! Thanks for this PR 🙌🏻
With public members in the config structs the public API breaks each time we're adding new options as the users MUST or MUST NOT add
.. Default::default()
depending on whether they're setting all options or not. So adding new options breaks for those users who use all options.This change hides the members from the users and replaces access by dedicated setter functions for each option so adding new options does not break API in the future. (This change obviously is an API break in itself.)