From ddaa99c20952be801efdbc0d2f377e42d961c97b Mon Sep 17 00:00:00 2001 From: "Sikkema, Isaac" Date: Fri, 16 Jun 2023 15:22:26 -0400 Subject: [PATCH] Add optional serde support for FieldData --- Cargo.toml | 3 ++- src/lib.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 658567c..b29e573 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ maintenance = { status = "passively-maintained" } bitflags = "1.2" embedded-hal = "=1.0.0-alpha.5" log = "0.4" +serde = { version = "1.0", optional = true, default-features = false } [dev-dependencies] env_logger = "0.9" @@ -26,4 +27,4 @@ tokio = {version = "1.5", features = ["full"] } url = "2.1" [target.'cfg(target_os = "linux")'.dev-dependencies] -linux-embedded-hal = "0.4.0-alpha.1" \ No newline at end of file +linux-embedded-hal = "0.4.0-alpha.1" diff --git a/src/lib.rs b/src/lib.rs index 45320b5..c43895e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,6 +101,9 @@ use core::{marker::PhantomData, result}; use embedded_hal as hal; use log::{debug, error, info}; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + /// BME680 General config pub const BME680_POLL_PERIOD_MS: u8 = 10; @@ -299,6 +302,8 @@ impl Clone for CalibData { /// Contains read sensors values e.g. temperature, pressure, humidity etc. #[derive(Debug, Default, Copy)] +#[cfg(feature = "serde")] +#[derive(Serialize, Deserialize)] #[repr(C)] pub struct FieldData { /// Contains new_data, gasm_valid & heat_stab