瀏覽代碼

socket: remove all uses of crate::{Error, Result};

Dario Nieuwenhuis 2 年之前
父節點
當前提交
0e1ba69ade
共有 5 個文件被更改,包括 25 次插入31 次删除
  1. 1 2
      src/socket/dhcpv4.rs
  2. 9 11
      src/socket/icmp.rs
  3. 8 9
      src/socket/raw.rs
  4. 2 3
      src/socket/tcp.rs
  5. 5 6
      src/socket/udp.rs

+ 1 - 2
src/socket/dhcpv4.rs

@@ -701,7 +701,6 @@ mod test {
 
     use super::*;
     use crate::wire::EthernetAddress;
-    use crate::Error;
 
     // =========================================================================================//
     // Helper functions
@@ -771,7 +770,7 @@ mod test {
                         None => panic!("Too many reprs emitted"),
                     }
                     i += 1;
-                    Ok::<_, Error>(())
+                    Ok::<_, ()>(())
                 });
         }
 

+ 9 - 11
src/socket/icmp.rs

@@ -619,7 +619,6 @@ mod tests_common {
 mod test_ipv4 {
     use super::tests_common::*;
     use crate::wire::{Icmpv4DstUnreachable, IpEndpoint, Ipv4Address};
-    use crate::Error;
 
     const REMOTE_IPV4: Ipv4Address = Ipv4Address([192, 168, 1, 2]);
     const LOCAL_IPV4: Ipv4Address = Ipv4Address([192, 168, 1, 1]);
@@ -696,9 +695,9 @@ mod test_ipv4 {
             socket.dispatch(&mut cx, |_, (ip_repr, icmp_repr)| {
                 assert_eq!(ip_repr, LOCAL_IPV4_REPR);
                 assert_eq!(icmp_repr, ECHOV4_REPR.into());
-                Err(Error::Unaddressable)
+                Err(())
             }),
-            Err(Error::Unaddressable)
+            Err(())
         );
         // buffer is not taken off of the tx queue due to the error
         assert!(!socket.can_send());
@@ -707,7 +706,7 @@ mod test_ipv4 {
             socket.dispatch(&mut cx, |_, (ip_repr, icmp_repr)| {
                 assert_eq!(ip_repr, LOCAL_IPV4_REPR);
                 assert_eq!(icmp_repr, ECHOV4_REPR.into());
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );
@@ -743,7 +742,7 @@ mod test_ipv4 {
                         hop_limit: 0x2a,
                     })
                 );
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );
@@ -861,7 +860,6 @@ mod test_ipv6 {
     use super::tests_common::*;
 
     use crate::wire::{Icmpv6DstUnreachable, IpEndpoint, Ipv6Address};
-    use crate::Error;
 
     const REMOTE_IPV6: Ipv6Address =
         Ipv6Address([0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]);
@@ -911,7 +909,7 @@ mod test_ipv6 {
 
         assert_eq!(
             socket.dispatch(&mut cx, |_, _| unreachable!()),
-            Ok::<_, Error>(())
+            Ok::<_, ()>(())
         );
 
         // This buffer is too long
@@ -944,9 +942,9 @@ mod test_ipv6 {
             socket.dispatch(&mut cx, |_, (ip_repr, icmp_repr)| {
                 assert_eq!(ip_repr, LOCAL_IPV6_REPR);
                 assert_eq!(icmp_repr, ECHOV6_REPR.into());
-                Err(Error::Unaddressable)
+                Err(())
             }),
-            Err(Error::Unaddressable)
+            Err(())
         );
         // buffer is not taken off of the tx queue due to the error
         assert!(!socket.can_send());
@@ -955,7 +953,7 @@ mod test_ipv6 {
             socket.dispatch(&mut cx, |_, (ip_repr, icmp_repr)| {
                 assert_eq!(ip_repr, LOCAL_IPV6_REPR);
                 assert_eq!(icmp_repr, ECHOV6_REPR.into());
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );
@@ -996,7 +994,7 @@ mod test_ipv6 {
                         hop_limit: 0x2a,
                     })
                 );
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );

+ 8 - 9
src/socket/raw.rs

@@ -387,7 +387,6 @@ mod test {
     use crate::wire::{Ipv4Address, Ipv4Repr};
     #[cfg(feature = "proto-ipv6")]
     use crate::wire::{Ipv6Address, Ipv6Repr};
-    use crate::Error;
 
     fn buffer(packets: usize) -> PacketBuffer<'static> {
         PacketBuffer::new(vec![PacketMetadata::EMPTY; packets], vec![0; 48 * packets])
@@ -484,7 +483,7 @@ mod test {
                     assert!(socket.can_send());
                     assert_eq!(
                         socket.dispatch(&mut cx, |_, _| unreachable!()),
-                        Ok::<_, Error>(())
+                        Ok::<_, ()>(())
                     );
 
                     assert_eq!(socket.send_slice(&$packet[..]), Ok(()));
@@ -495,9 +494,9 @@ mod test {
                         socket.dispatch(&mut cx, |_, (ip_repr, ip_payload)| {
                             assert_eq!(ip_repr, $hdr);
                             assert_eq!(ip_payload, &$payload);
-                            Err(Error::Unaddressable)
+                            Err(())
                         }),
-                        Err(Error::Unaddressable)
+                        Err(())
                     );
                     assert!(!socket.can_send());
 
@@ -505,7 +504,7 @@ mod test {
                         socket.dispatch(&mut cx, |_, (ip_repr, ip_payload)| {
                             assert_eq!(ip_repr, $hdr);
                             assert_eq!(ip_payload, &$payload);
-                            Ok::<_, Error>(())
+                            Ok::<_, ()>(())
                         }),
                         Ok(())
                     );
@@ -572,7 +571,7 @@ mod test {
             assert_eq!(socket.send_slice(&wrong_version[..]), Ok(()));
             assert_eq!(
                 socket.dispatch(&mut cx, |_, _| unreachable!()),
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             );
 
             let mut wrong_protocol = ipv4_locals::PACKET_BYTES;
@@ -581,7 +580,7 @@ mod test {
             assert_eq!(socket.send_slice(&wrong_protocol[..]), Ok(()));
             assert_eq!(
                 socket.dispatch(&mut cx, |_, _| unreachable!()),
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             );
         }
         #[cfg(feature = "proto-ipv6")]
@@ -595,7 +594,7 @@ mod test {
             assert_eq!(socket.send_slice(&wrong_version[..]), Ok(()));
             assert_eq!(
                 socket.dispatch(&mut cx, |_, _| unreachable!()),
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             );
 
             let mut wrong_protocol = ipv6_locals::PACKET_BYTES;
@@ -604,7 +603,7 @@ mod test {
             assert_eq!(socket.send_slice(&wrong_protocol[..]), Ok(()));
             assert_eq!(
                 socket.dispatch(&mut cx, |_, _| unreachable!()),
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             );
         }
     }

+ 2 - 3
src/socket/tcp.rs

@@ -2313,7 +2313,6 @@ impl<'a> fmt::Write for Socket<'a> {
 mod test {
     use super::*;
     use crate::wire::IpRepr;
-    use crate::Error;
     use core::i32;
     use std::ops::{Deref, DerefMut};
     use std::vec::Vec;
@@ -2465,7 +2464,7 @@ mod test {
 
     fn recv<F>(socket: &mut TestSocket, timestamp: Instant, mut f: F)
     where
-        F: FnMut(Result<TcpRepr, Error>),
+        F: FnMut(Result<TcpRepr, ()>),
     {
         socket.cx.set_now(timestamp);
 
@@ -6310,7 +6309,7 @@ mod test {
         assert_eq!(
             s.socket.dispatch(&mut s.cx, |_, (ip_repr, _)| {
                 assert_eq!(ip_repr.hop_limit(), 0x2a);
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );

+ 5 - 6
src/socket/udp.rs

@@ -488,7 +488,6 @@ impl<'a> Socket<'a> {
 mod test {
     use super::*;
     use crate::wire::{IpRepr, UdpRepr};
-    use crate::Error;
 
     fn buffer(packets: usize) -> PacketBuffer<'static> {
         PacketBuffer::new(vec![PacketMetadata::EMPTY; packets], vec![0; 16 * packets])
@@ -637,7 +636,7 @@ mod test {
         assert!(socket.can_send());
         assert_eq!(
             socket.dispatch(&mut cx, |_, _| unreachable!()),
-            Ok::<_, Error>(())
+            Ok::<_, ()>(())
         );
 
         assert_eq!(socket.send_slice(b"abcdef", REMOTE_END), Ok(()));
@@ -652,9 +651,9 @@ mod test {
                 assert_eq!(ip_repr, LOCAL_IP_REPR);
                 assert_eq!(udp_repr, LOCAL_UDP_REPR);
                 assert_eq!(payload, PAYLOAD);
-                Err(Error::Unaddressable)
+                Err(())
             }),
-            Err(Error::Unaddressable)
+            Err(())
         );
         assert!(!socket.can_send());
 
@@ -663,7 +662,7 @@ mod test {
                 assert_eq!(ip_repr, LOCAL_IP_REPR);
                 assert_eq!(udp_repr, LOCAL_UDP_REPR);
                 assert_eq!(payload, PAYLOAD);
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );
@@ -759,7 +758,7 @@ mod test {
                         hop_limit: 0x2a,
                     })
                 );
-                Ok::<_, Error>(())
+                Ok::<_, ()>(())
             }),
             Ok(())
         );