diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/network/dns/resolver.rs | 4 | ||||
-rw-r--r-- | src/os/shared.rs | 4 | ||||
-rw-r--r-- | src/tests/fakes/fake_input.rs | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 1940c7f..2ba7f97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ const DISPLAY_DELTA: Duration = Duration::from_millis(1000); fn main() -> anyhow::Result<()> { let opts = Opt::parse(); - let os_input = os::get_input(&opts.interface, !opts.no_resolve, &opts.dns_server)?; + let os_input = os::get_input(opts.interface.as_deref(), !opts.no_resolve, opts.dns_server)?; if opts.raw { let terminal_backend = RawTerminalBackend {}; diff --git a/src/network/dns/resolver.rs b/src/network/dns/resolver.rs index c8a19f7..8df3fb7 100644 --- a/src/network/dns/resolver.rs +++ b/src/network/dns/resolver.rs @@ -15,12 +15,12 @@ pub trait Lookup { pub struct Resolver(TokioAsyncResolver); impl Resolver { - pub async fn new(dns_server: &Option<Ipv4Addr>) -> anyhow::Result<Self> { + pub async fn new(dns_server: Option<Ipv4Addr>) -> anyhow::Result<Self> { let resolver = match dns_server { Some(dns_server_address) => { let mut config = ResolverConfig::new(); let options = ResolverOpts::default(); - let socket = SocketAddr::V4(SocketAddrV4::new(*dns_server_address, 53)); + let socket = SocketAddr::V4(SocketAddrV4::new(dns_server_address, 53)); let nameserver_config = NameServerConfig { socket_addr: socket, protocol: Protocol::Udp, diff --git a/src/os/shared.rs b/src/os/shared.rs index 71e491c..5383db3 100644 --- a/src/os/shared.rs +++ b/src/os/shared.rs @@ -143,9 +143,9 @@ where } pub fn get_input( - interface_name: &Option<String>, + interface_name: Option<&str>, resolve: bool, - dns_server: &Option<Ipv4Addr>, + dns_server: Option<Ipv4Addr>, ) -> anyhow::Result<OsInputOutput> { let network_interfaces = if let Some(name) = interface_name { match get_interface(name) { diff --git a/src/tests/fakes/fake_input.rs b/src/tests/fakes/fake_input.rs index e064b7e..27b5c5e 100644 --- a/src/tests/fakes/fake_input.rs +++ b/src/tests/fakes/fake_input.rs @@ -56,10 +56,10 @@ impl NetworkFrames { current_index: 0, }) } - fn next_packet(&mut self) -> &Option<Vec<u8>> { + fn next_packet(&mut self) -> Option<&[u8]> { let next_index = self.current_index; self.current_index += 1; - &self.packets[next_index] + self.packets.get(next_index).and_then(|p| p.as_deref()) } } impl DataLinkReceiver for NetworkFrames { |