summaryrefslogtreecommitdiffstats
path: root/crates/core/c8y_smartrest
diff options
context:
space:
mode:
Diffstat (limited to 'crates/core/c8y_smartrest')
-rw-r--r--crates/core/c8y_smartrest/Cargo.toml2
-rw-r--r--crates/core/c8y_smartrest/src/error.rs6
-rw-r--r--crates/core/c8y_smartrest/src/operations.rs12
-rw-r--r--crates/core/c8y_smartrest/src/smartrest_serializer.rs12
4 files changed, 14 insertions, 18 deletions
diff --git a/crates/core/c8y_smartrest/Cargo.toml b/crates/core/c8y_smartrest/Cargo.toml
index fea61122..01c271b3 100644
--- a/crates/core/c8y_smartrest/Cargo.toml
+++ b/crates/core/c8y_smartrest/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "c8y_smartrest"
-version = "0.7.1"
+version = "0.7.2"
authors = ["thin-edge.io team <info@thin-edge.io>"]
edition = "2021"
rust-version = "1.58.1"
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)