-
Notifications
You must be signed in to change notification settings - Fork 43
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: extract match addr to type as a function #205
feat: extract match addr to type as a function #205
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.
Thanks for your PR! It's a nice refactoring! Minor comments inline.
src/dns_parser.rs
Outdated
@@ -52,6 +52,14 @@ pub const FLAGS_AA: u16 = 0x0400; // mask for Authoritative answer bit | |||
|
|||
pub type DnsRecordBox = Box<dyn DnsRecordExt + Send>; | |||
|
|||
#[inline] | |||
pub const fn ip_address_to_type(address: IpAddr) -> u16 { |
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.
nitpick: do you mind pass address
as &IpAddr
?
src/service_daemon.rs
Outdated
IpAddr::V4(_) => zc.send_query(hostname, TYPE_A), | ||
IpAddr::V6(_) => zc.send_query(hostname, TYPE_AAAA), | ||
} | ||
zc.send_query(hostname, ip_address_to_type(*ip_addr)); |
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.
If we pass &IpAddr
for the function, then no need to have *
here.
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.
Nice! LGTM, thanks!
I have seen the repeated usage of
in multiple places, although this is a very simple operation, it could be extracted into a function (which is what this PR does).
I'm not really sure if the function name
ip_address_to_type
and its location are appropriate.