diff options
author | initard <solo@softwareag.com> | 2022-06-11 18:35:38 +0100 |
---|---|---|
committer | initard <solo@softwareag.com> | 2022-06-16 15:18:10 +0100 |
commit | 881eddd332567b8cc61f1417e93569743ad93999 (patch) | |
tree | 665be3078258054bf539b3a58476eef20e72979e /crates/core | |
parent | dcc7e45ca49fb99cdaa1ce232a698695dc2577bc (diff) |
c8y_smartrest fixing clippy warnings #825
Signed-off-by: initard <solo@softwareag.com>
Diffstat (limited to 'crates/core')
-rw-r--r-- | crates/core/c8y_smartrest/src/error.rs | 6 | ||||
-rw-r--r-- | crates/core/c8y_smartrest/src/operations.rs | 12 | ||||
-rw-r--r-- | crates/core/c8y_smartrest/src/smartrest_serializer.rs | 12 |
3 files changed, 13 insertions, 17 deletions
diff --git a/crates/core/c8y_smartrest/src/error.rs b/crates/core/c8y_smartrest/src/error.rs index 10a867d3..465a6cab 100644 --- a/crates/core/c8y_smartrest/src/error.rs +++ b/crates/core/c8y_smartrest/src/error.rs @@ -1,6 +1,10 @@ use agent_interface::SoftwareUpdateResponse; use std::path::PathBuf; +// allowing large size difference between variants warning, +// because the enum `SmartRestSerializerError` is already Boxed +// in `SMCumulocityMapperError` +#[allow(clippy::large_enum_variant)] #[derive(thiserror::Error, Debug)] pub enum SmartRestSerializerError { #[error("The operation status is not supported. {response:?}")] @@ -77,7 +81,7 @@ pub enum SMCumulocityMapperError { FromReqwest(#[from] reqwest::Error), #[error(transparent)] - FromSmartRestSerializer(#[from] SmartRestSerializerError), + FromSmartRestSerializer(#[from] Box<SmartRestSerializerError>), #[error(transparent)] FromSmartRestDeserializer(#[from] SmartRestDeserializerError), diff --git a/crates/core/c8y_smartrest/src/operations.rs b/crates/core/c8y_smartrest/src/operations.rs index 5304b8b2..87e6aee9 100644 --- a/crates/core/c8y_smartrest/src/operations.rs +++ b/crates/core/c8y_smartrest/src/operations.rs @@ -42,25 +42,15 @@ impl Operation { } } -#[derive(Debug, Clone)] +#[derive(Debug, Default, Clone)] pub struct Operations { operations: Vec<Operation>, operations_by_trigger: HashMap<String, usize>, } -impl Default for Operations { - fn default() -> Self { - Self { - operations: vec![], - operations_by_trigger: HashMap::new(), - } - } -} - impl Operations { pub fn add_operation(&mut self, operation: Operation) { if self.operations.iter().any(|o| o.name.eq(&operation.name)) { - return; } else { if let Some(detail) = operation.exec() { if let Some(on_message) = &detail.on_message { diff --git a/crates/core/c8y_smartrest/src/smartrest_serializer.rs b/crates/core/c8y_smartrest/src/smartrest_serializer.rs index 503a345b..4581a2cf 100644 --- a/crates/core/c8y_smartrest/src/smartrest_serializer.rs +++ b/crates/core/c8y_smartrest/src/smartrest_serializer.rs @@ -201,11 +201,13 @@ where } fn serialize_smartrest<S: Serialize>(record: S) -> Result<String, SmartRestSerializerError> { - let mut wtr = WriterBuilder::new() - .has_headers(false) - .quote_style(QuoteStyle::Never) - .double_quote(false) - .from_writer(vec![]); + let mut wtr = Box::new( + WriterBuilder::new() + .has_headers(false) + .quote_style(QuoteStyle::Never) + .double_quote(false) + .from_writer(vec![]), + ); wtr.serialize(record)?; let csv = String::from_utf8(wtr.into_inner()?)?; Ok(csv) |