summaryrefslogtreecommitdiffstats
path: root/tedge_config
diff options
context:
space:
mode:
authorLukasz Woznicki <75632179+makr11st@users.noreply.github.com>2021-09-16 21:45:41 +0100
committerGitHub <noreply@github.com>2021-09-16 21:45:41 +0100
commit91b90f31c7a96d44312fe3c33a299f4783417ba2 (patch)
tree53991502fbd493db65fcf6bd0788d1632e9def99 /tedge_config
parentb8950d2635060576ff1ba60f6d8867083a7dccfb (diff)
Clippy lints fixes for latest code (#433)
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'tedge_config')
-rw-r--r--tedge_config/src/error.rs10
-rw-r--r--tedge_config/src/models/flag.rs4
-rw-r--r--tedge_config/src/models/port.rs6
-rw-r--r--tedge_config/src/tedge_config_repository.rs2
-rw-r--r--tedge_config/tests/test_tedge_config.rs6
5 files changed, 14 insertions, 14 deletions
diff --git a/tedge_config/src/error.rs b/tedge_config/src/error.rs
index a90f719b..f1e23642 100644
--- a/tedge_config/src/error.rs
+++ b/tedge_config/src/error.rs
@@ -1,19 +1,19 @@
#[derive(thiserror::Error, Debug)]
pub enum TEdgeConfigError {
#[error("TOML parse error")]
- TOMLParseError(#[from] toml::de::Error),
+ FromTOMLParse(#[from] toml::de::Error),
#[error("TOML serialization error")]
- InvalidTOMLError(#[from] toml::ser::Error),
+ FromInvalidTOML(#[from] toml::ser::Error),
#[error("I/O error")]
- IOError(#[from] std::io::Error),
+ FromIo(#[from] std::io::Error),
#[error(transparent)]
- ConfigSettingError(#[from] crate::ConfigSettingError),
+ FromConfigSetting(#[from] crate::ConfigSettingError),
#[error(transparent)]
- InvalidConfigUrl(#[from] crate::models::InvalidConnectUrl),
+ FromInvalidConfigUrl(#[from] crate::models::InvalidConnectUrl),
#[error("Config file not found: {0}")]
ConfigFileNotFound(std::path::PathBuf),
diff --git a/tedge_config/src/models/flag.rs b/tedge_config/src/models/flag.rs
index debdbe36..3144a677 100644
--- a/tedge_config/src/models/flag.rs
+++ b/tedge_config/src/models/flag.rs
@@ -57,14 +57,14 @@ mod tests {
fn convert_string_true_to_bool_true() {
let input = "true".to_string();
let output: bool = Flag::try_from(input).unwrap().into();
- assert_eq!(output, true);
+ assert!(output);
}
#[test]
fn convert_string_false_to_bool_false() {
let input = "false".to_string();
let output: bool = Flag::try_from(input).unwrap().into();
- assert_eq!(output, false);
+ assert!(!output);
}
#[test]
diff --git a/tedge_config/src/models/port.rs b/tedge_config/src/models/port.rs
index f6cfef9c..cb7e1c70 100644
--- a/tedge_config/src/models/port.rs
+++ b/tedge_config/src/models/port.rs
@@ -29,9 +29,9 @@ impl TryInto<String> for Port {
}
}
-impl Into<u16> for Port {
- fn into(self) -> u16 {
- self.0
+impl From<Port> for u16 {
+ fn from(val: Port) -> Self {
+ val.0
}
}
diff --git a/tedge_config/src/tedge_config_repository.rs b/tedge_config/src/tedge_config_repository.rs
index 433d3013..a7741165 100644
--- a/tedge_config/src/tedge_config_repository.rs
+++ b/tedge_config/src/tedge_config_repository.rs
@@ -79,7 +79,7 @@ impl TEdgeConfigRepository {
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
Err(TEdgeConfigError::ConfigFileNotFound(path))
}
- Err(err) => Err(TEdgeConfigError::IOError(err)),
+ Err(err) => Err(TEdgeConfigError::FromIo(err)),
}
}
diff --git a/tedge_config/tests/test_tedge_config.rs b/tedge_config/tests/test_tedge_config.rs
index 95ce4d26..6eb8fbcd 100644
--- a/tedge_config/tests/test_tedge_config.rs
+++ b/tedge_config/tests/test_tedge_config.rs
@@ -521,7 +521,7 @@ hello="tedge"
assert_matches!(
result,
- Err(TEdgeConfigError::TOMLParseError(_)),
+ Err(TEdgeConfigError::FromTOMLParse(_)),
"Expected the parsing to fail with TOMLParseError"
);
Ok(())
@@ -541,7 +541,7 @@ port = "1883"
"invalid type: string \"1883\", expected u16 for key `mqtt.port` at line 3 column 8";
match result {
- Err(TEdgeConfigError::TOMLParseError(err)) => assert_eq!(err.to_string(), expected_err),
+ Err(TEdgeConfigError::FromTOMLParse(err)) => assert_eq!(err.to_string(), expected_err),
_ => assert!(false, "Expected the parsing to fail with TOMLParseError"),
}
@@ -560,7 +560,7 @@ fn test_parse_invalid_toml_file() -> Result<(), TEdgeConfigError> {
assert_matches!(
result,
- Err(TEdgeConfigError::TOMLParseError(_)),
+ Err(TEdgeConfigError::FromTOMLParse(_)),
"Expected the parsing to fail with TOMLParseError"
);
Ok(())