This commit is contained in:
dynco-nym
2025-05-16 16:24:46 +02:00
parent f47650d6c8
commit b7da75a18c
11 changed files with 30 additions and 28 deletions
+2
View File
@@ -1,6 +1,8 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
#![allow(clippy::result_large_err)]
use std::error::Error;
use clap::{crate_name, crate_version, Parser};
+3 -1
View File
@@ -1,3 +1,5 @@
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-panic-in-tests = true
allow-panic-in-tests = true
large-error-threshold = 196
enum-variant-size-threshold = 1000
+1 -2
View File
@@ -48,8 +48,7 @@ pub mod nym_config {
log::trace!("Loading from file: {:#?}", filepath.as_ref().to_owned());
let config_contents = fs::read_to_string(filepath)?;
toml::from_str(&config_contents)
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
toml::from_str(&config_contents).map_err(io::Error::other)
}
}
}
+1 -2
View File
@@ -151,8 +151,7 @@ where
let content = fs::read_to_string(path)?;
// TODO: should we be preserving original error type instead?
deserialize_config_from_toml_str(&content)
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
deserialize_config_from_toml_str(&content).map_err(io::Error::other)
}
//
+6 -9
View File
@@ -54,14 +54,11 @@ where
let key_pem = read_pem_file(path)?;
if T::pem_type() != key_pem.tag {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"unexpected key pem tag. Got '{}', expected: '{}'",
key_pem.tag,
T::pem_type()
),
));
return Err(io::Error::other(format!(
"unexpected key pem tag. Got '{}', expected: '{}'",
key_pem.tag,
T::pem_type()
)));
}
let key = match T::from_bytes(&key_pem.contents) {
@@ -84,7 +81,7 @@ fn read_pem_file<P: AsRef<Path>>(filepath: P) -> io::Result<Pem> {
let mut pem_bytes = File::open(filepath)?;
let mut buf = Vec::new();
pem_bytes.read_to_end(&mut buf)?;
pem::parse(&buf).map_err(|e| io::Error::new(io::ErrorKind::Other, e))
pem::parse(&buf).map_err(io::Error::other)
}
fn write_pem_file<P: AsRef<Path>>(filepath: P, data: Vec<u8>, tag: &str) -> io::Result<()> {
+1
View File
@@ -1,6 +1,7 @@
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
#![allow(clippy::result_large_err)]
#![warn(clippy::todo)]
#![warn(clippy::dbg_macro)]
+1
View File
@@ -1,6 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
#![allow(clippy::result_large_err)]
#![warn(clippy::expect_used)]
#![warn(clippy::unwrap_used)]
+1
View File
@@ -1,6 +1,7 @@
// Copyright 2023-2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
#![allow(clippy::result_large_err)]
#![warn(clippy::expect_used)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::todo)]
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::result_large_err)]
use clap::{crate_name, crate_version, Parser};
use nym_bin_common::bin_info_owned;
use nym_bin_common::logging::maybe_print_banner;
+8 -10
View File
@@ -212,19 +212,18 @@ where
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<std::result::Result<usize, std::io::Error>> {
ready!(self.tx.poll_ready_unpin(cx)).map_err(|_| {
std::io::Error::new(std::io::ErrorKind::Other, "failed to send packet to mixnet")
})?;
ready!(self.tx.poll_ready_unpin(cx))
.map_err(|_| std::io::Error::other("failed to send packet to mixnet"))?;
let input_message = self
.message_translator
.to_input_message(buf)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
.map_err(std::io::Error::other)?;
// Pass it to the mixnet sender
self.tx.start_send_unpin(input_message).map_err(|_| {
std::io::Error::new(std::io::ErrorKind::Other, "failed to send packet to mixnet")
})?;
self.tx
.start_send_unpin(input_message)
.map_err(|_| std::io::Error::other("failed to send packet to mixnet"))?;
Poll::Ready(Ok(buf.len()))
}
@@ -233,9 +232,8 @@ where
mut self: Pin<&mut Self>,
cx: &mut Context,
) -> Poll<std::result::Result<(), std::io::Error>> {
ready!(self.tx.poll_flush_unpin(cx)).map_err(|_| {
std::io::Error::new(std::io::ErrorKind::Other, "failed to send packet to mixnet")
})?;
ready!(self.tx.poll_flush_unpin(cx))
.map_err(|_| std::io::Error::other("failed to send packet to mixnet"))?;
Poll::Ready(Ok(()))
}
+4 -4
View File
@@ -152,7 +152,7 @@ impl UpgradePlan {
let mut upgrade_plan: UpgradePlan = fs::File::open(path)
.and_then(|file| {
serde_json::from_reader(file)
.map_err(|serde_json_err| io::Error::new(io::ErrorKind::Other, serde_json_err))
.map_err(io::Error::other)
})
.map_err(|source| NymvisorError::UpgradePlanLoadFailure {
path: path.to_path_buf(),
@@ -276,7 +276,7 @@ impl UpgradeInfo {
fs::File::open(path)
.and_then(|file| {
serde_json::from_reader(file)
.map_err(|serde_json_err| io::Error::new(io::ErrorKind::Other, serde_json_err))
.map_err(io::Error::other)
})
.map_err(|source| NymvisorError::UpgradeInfoLoadFailure {
path: path.to_path_buf(),
@@ -428,7 +428,7 @@ impl UpgradeHistory {
let mut history: UpgradeHistory = fs::File::open(path)
.and_then(|file| {
serde_json::from_reader(file)
.map_err(|serde_json_err| io::Error::new(io::ErrorKind::Other, serde_json_err))
.map_err(io::Error::other)
})
.map_err(|source| NymvisorError::UpgradeHistoryLoadFailure {
path: path.to_path_buf(),
@@ -483,7 +483,7 @@ impl CurrentVersionInfo {
fs::File::open(path)
.and_then(|file| {
serde_json::from_reader(file)
.map_err(|serde_json_err| io::Error::new(io::ErrorKind::Other, serde_json_err))
.map_err(io::Error::other)
})
.map_err(|source| NymvisorError::CurrentVersionInfoLoadFailure {
path: path.to_path_buf(),