aboutsummaryrefslogtreecommitdiff
path: root/embassy-net
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-09-03 00:35:21 +0200
committerGitHub <[email protected]>2023-09-03 00:35:21 +0200
commit9baa3bafb0330d58bd98c0a974968c97c54c53a5 (patch)
treec3b455ae417c41a1f2a57a5d7cf56d8bc3fb6606 /embassy-net
parent9d8c527308522698bfb6596bdb67bec826e0fb5a (diff)
parent360286e67c355d23a355f83bbb6586b3fa3b3a7e (diff)
Merge pull request #1854 from bugadani/str
embassy-{net, sync, time}: Use fmt::unwrap
Diffstat (limited to 'embassy-net')
-rw-r--r--embassy-net/src/device.rs4
-rw-r--r--embassy-net/src/lib.rs14
-rw-r--r--embassy-net/src/tcp.rs4
3 files changed, 11 insertions, 11 deletions
diff --git a/embassy-net/src/device.rs b/embassy-net/src/device.rs
index d29ab8970..8c2b7d31a 100644
--- a/embassy-net/src/device.rs
+++ b/embassy-net/src/device.rs
@@ -22,13 +22,13 @@ where
22 22
23 fn receive(&mut self, _timestamp: Instant) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> { 23 fn receive(&mut self, _timestamp: Instant) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)> {
24 self.inner 24 self.inner
25 .receive(self.cx.as_deref_mut().unwrap()) 25 .receive(unwrap!(self.cx.as_deref_mut()))
26 .map(|(rx, tx)| (RxTokenAdapter(rx), TxTokenAdapter(tx))) 26 .map(|(rx, tx)| (RxTokenAdapter(rx), TxTokenAdapter(tx)))
27 } 27 }
28 28
29 /// Construct a transmit token. 29 /// Construct a transmit token.
30 fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>> { 30 fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>> {
31 self.inner.transmit(self.cx.as_deref_mut().unwrap()).map(TxTokenAdapter) 31 self.inner.transmit(unwrap!(self.cx.as_deref_mut())).map(TxTokenAdapter)
32 } 32 }
33 33
34 /// Get a description of device capabilities. 34 /// Get a description of device capabilities.
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index 3a385fad6..c2575267c 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -616,7 +616,7 @@ impl<D: Driver + 'static> Inner<D> {
616 } 616 }
617 617
618 // Configure it 618 // Configure it
619 let socket = _s.sockets.get_mut::<dhcpv4::Socket>(self.dhcp_socket.unwrap()); 619 let socket = _s.sockets.get_mut::<dhcpv4::Socket>(unwrap!(self.dhcp_socket));
620 socket.set_ignore_naks(c.ignore_naks); 620 socket.set_ignore_naks(c.ignore_naks);
621 socket.set_max_lease_duration(c.max_lease_duration.map(crate::time::duration_to_smoltcp)); 621 socket.set_max_lease_duration(c.max_lease_duration.map(crate::time::duration_to_smoltcp));
622 socket.set_ports(c.server_port, c.client_port); 622 socket.set_ports(c.server_port, c.client_port);
@@ -656,12 +656,12 @@ impl<D: Driver + 'static> Inner<D> {
656 debug!(" IP address: {:?}", config.address); 656 debug!(" IP address: {:?}", config.address);
657 debug!(" Default gateway: {:?}", config.gateway); 657 debug!(" Default gateway: {:?}", config.gateway);
658 658
659 addrs.push(IpCidr::Ipv4(config.address)).unwrap(); 659 unwrap!(addrs.push(IpCidr::Ipv4(config.address)).ok());
660 gateway_v4 = config.gateway.into(); 660 gateway_v4 = config.gateway.into();
661 #[cfg(feature = "dns")] 661 #[cfg(feature = "dns")]
662 for s in &config.dns_servers { 662 for s in &config.dns_servers {
663 debug!(" DNS server: {:?}", s); 663 debug!(" DNS server: {:?}", s);
664 dns_servers.push(s.clone().into()).unwrap(); 664 unwrap!(dns_servers.push(s.clone().into()).ok());
665 } 665 }
666 } else { 666 } else {
667 info!("IPv4: DOWN"); 667 info!("IPv4: DOWN");
@@ -673,12 +673,12 @@ impl<D: Driver + 'static> Inner<D> {
673 debug!(" IP address: {:?}", config.address); 673 debug!(" IP address: {:?}", config.address);
674 debug!(" Default gateway: {:?}", config.gateway); 674 debug!(" Default gateway: {:?}", config.gateway);
675 675
676 addrs.push(IpCidr::Ipv6(config.address)).unwrap(); 676 unwrap!(addrs.push(IpCidr::Ipv6(config.address)).ok());
677 gateway_v6 = config.gateway.into(); 677 gateway_v6 = config.gateway.into();
678 #[cfg(feature = "dns")] 678 #[cfg(feature = "dns")]
679 for s in &config.dns_servers { 679 for s in &config.dns_servers {
680 debug!(" DNS server: {:?}", s); 680 debug!(" DNS server: {:?}", s);
681 dns_servers.push(s.clone().into()).unwrap(); 681 unwrap!(dns_servers.push(s.clone().into()).ok());
682 } 682 }
683 } else { 683 } else {
684 info!("IPv6: DOWN"); 684 info!("IPv6: DOWN");
@@ -690,13 +690,13 @@ impl<D: Driver + 'static> Inner<D> {
690 // Apply gateways 690 // Apply gateways
691 #[cfg(feature = "proto-ipv4")] 691 #[cfg(feature = "proto-ipv4")]
692 if let Some(gateway) = gateway_v4 { 692 if let Some(gateway) = gateway_v4 {
693 s.iface.routes_mut().add_default_ipv4_route(gateway).unwrap(); 693 unwrap!(s.iface.routes_mut().add_default_ipv4_route(gateway));
694 } else { 694 } else {
695 s.iface.routes_mut().remove_default_ipv4_route(); 695 s.iface.routes_mut().remove_default_ipv4_route();
696 } 696 }
697 #[cfg(feature = "proto-ipv6")] 697 #[cfg(feature = "proto-ipv6")]
698 if let Some(gateway) = gateway_v6 { 698 if let Some(gateway) = gateway_v6 {
699 s.iface.routes_mut().add_default_ipv6_route(gateway).unwrap(); 699 unwrap!(s.iface.routes_mut().add_default_ipv6_route(gateway));
700 } else { 700 } else {
701 s.iface.routes_mut().remove_default_ipv6_route(); 701 s.iface.routes_mut().remove_default_ipv6_route();
702 } 702 }
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs
index c92ad2d2e..a12fd382a 100644
--- a/embassy-net/src/tcp.rs
+++ b/embassy-net/src/tcp.rs
@@ -440,7 +440,7 @@ impl<'d> TcpIo<'d> {
440 Poll::Ready(Err(Error::ConnectionReset)) 440 Poll::Ready(Err(Error::ConnectionReset))
441 } 441 }
442 } else { 442 } else {
443 Poll::Ready(match s.send(f.take().unwrap()) { 443 Poll::Ready(match s.send(unwrap!(f.take())) {
444 // Connection reset. TODO: this can also be timeouts etc, investigate. 444 // Connection reset. TODO: this can also be timeouts etc, investigate.
445 Err(tcp::SendError::InvalidState) => Err(Error::ConnectionReset), 445 Err(tcp::SendError::InvalidState) => Err(Error::ConnectionReset),
446 Ok(r) => Ok(r), 446 Ok(r) => Ok(r),
@@ -468,7 +468,7 @@ impl<'d> TcpIo<'d> {
468 Poll::Ready(Err(Error::ConnectionReset)) 468 Poll::Ready(Err(Error::ConnectionReset))
469 } 469 }
470 } else { 470 } else {
471 Poll::Ready(match s.recv(f.take().unwrap()) { 471 Poll::Ready(match s.recv(unwrap!(f.take())) {
472 // Connection reset. TODO: this can also be timeouts etc, investigate. 472 // Connection reset. TODO: this can also be timeouts etc, investigate.
473 Err(tcp::RecvError::Finished) | Err(tcp::RecvError::InvalidState) => { 473 Err(tcp::RecvError::Finished) | Err(tcp::RecvError::InvalidState) => {
474 Err(Error::ConnectionReset) 474 Err(Error::ConnectionReset)