Explorar el Código

chore: clippy

skoupidi hace 1 año
padre
commit
ee2fc468be
Se han modificado 3 ficheros con 12 adiciones y 24 borrados
  1. 7 19
      src/net/transport/tor.rs
  2. 3 3
      src/sdk/src/crypto/merkle_node.rs
  3. 2 2
      src/zkas/error.rs

+ 7 - 19
src/net/transport/tor.rs

@@ -98,10 +98,7 @@ impl TorDialer {
             Ok(client) => client,
             Err(e) => {
                 warn!("{}", e.report());
-                return Err(io::Error::new(
-                    ErrorKind::Other,
-                    "Internal Tor error, see logged warning",
-                ))
+                return Err(io::Error::other("Internal Tor error, see logged warning"))
             }
         };
 
@@ -123,10 +120,7 @@ impl TorDialer {
 
                     Either::Left((Err(e), _)) => {
                         warn!("{}", e.report());
-                        Err(io::Error::new(
-                            ErrorKind::Other,
-                            "Internal Tor error, see logged warning",
-                        ))
+                        Err(io::Error::other("Internal Tor error, see logged warning"))
                     }
 
                     Either::Right((_, _)) => Err(io::ErrorKind::TimedOut.into()),
@@ -142,10 +136,7 @@ impl TorDialer {
                         // https://docs.rs/arti-client/latest/arti_client/#reporting-arti-errors
                         // https://gitlab.torproject.org/tpo/core/arti/-/issues/1086
                         warn!("{}", e.report());
-                        Err(io::Error::new(
-                            ErrorKind::Other,
-                            "Internal Tor error, see logged warning",
-                        ))
+                        Err(io::Error::other("Internal Tor error, see logged warning"))
                     }
                 }
             }
@@ -190,10 +181,7 @@ impl TorListener {
             Ok(client) => client,
             Err(e) => {
                 warn!("{}", e.report());
-                return Err(io::Error::new(
-                    ErrorKind::Other,
-                    "Internal Tor error, see logged warning",
-                ))
+                return Err(io::Error::other("Internal Tor error, see logged warning"))
             }
         };
 
@@ -206,7 +194,7 @@ impl TorListener {
                     target: "net::tor::do_listen",
                     "[P2P] Failed to create OnionServiceConfig: {}", e,
                 );
-                return Err(io::Error::new(ErrorKind::Other, "Internal Tor error"))
+                return Err(io::Error::other("Internal Tor error"))
             }
         };
 
@@ -217,7 +205,7 @@ impl TorListener {
                     target: "net::tor::do_listen",
                     "[P2P] Failed to launch Onion Service: {}", e,
                 );
-                return Err(io::Error::new(ErrorKind::Other, "Internal Tor error"))
+                return Err(io::Error::other("Internal Tor error"))
             }
         };
 
@@ -292,7 +280,7 @@ impl PtListener for TorListenerIntern {
                     target: "net::tor::PtListener::next",
                     "[P2P] Failed accepting Tor StreamRequest: {}", e,
                 );
-                return Err(io::Error::new(ErrorKind::Other, "Internal Tor error"))
+                return Err(io::Error::other("Internal Tor error"))
             }
         };
 

+ 3 - 3
src/sdk/src/crypto/merkle_node.rs

@@ -106,18 +106,18 @@ impl FromStr for MerkleNode {
     fn from_str(s: &str) -> Result<Self, Self::Err> {
         let bytes = match bs58::decode(s).into_vec() {
             Ok(v) => v,
-            Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
+            Err(e) => return Err(io::Error::other(e)),
         };
 
         if bytes.len() != 32 {
-            return Err(io::Error::new(io::ErrorKind::Other, "Length of decoded bytes is not 32"))
+            return Err(io::Error::other("Length of decoded bytes is not 32"))
         }
 
         if let Some(merkle_node) = Self::from_bytes(bytes.try_into().unwrap()) {
             return Ok(merkle_node)
         }
 
-        Err(io::Error::new(io::ErrorKind::Other, "Invalid bytes for MerkleNode"))
+        Err(io::Error::other("Invalid bytes for MerkleNode"))
     }
 }
 

+ 2 - 2
src/zkas/error.rs

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use std::io::{self, Error, ErrorKind, Write};
+use std::io::{self, Error, Write};
 
 pub(super) struct ErrorEmitter {
     namespace: String,
@@ -46,7 +46,7 @@ impl ErrorEmitter {
     pub fn abort(&self, msg: &str, ln: usize, col: usize) -> Error {
         let m = self.fmt(msg.to_string(), ln, col);
         self.emit("error", &m);
-        Error::new(ErrorKind::Other, m)
+        Error::other(m)
     }
 
     pub fn warn(&self, msg: &str, ln: usize, col: usize) {