From 803536940b3166aa30f26bbb6c4228abf840a7b2 Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Thu, 24 Aug 2023 09:55:19 -0600 Subject: [PATCH] using `serde_derive` crate directly rather than `serde` `derive` feature --- rust/Cargo.toml | 4 +++- rust/fastsim-cli/Cargo.toml | 1 + rust/fastsim-cli/src/bin/fastsim-cli.rs | 2 +- rust/fastsim-core/Cargo.toml | 3 ++- rust/fastsim-core/src/imports.rs | 3 +-- rust/fastsim-core/src/simdrivelabel.rs | 2 +- rust/fastsim-core/src/traits.rs | 4 ++-- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 234b4de9..bc77e776 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -17,6 +17,8 @@ codegen-units = 1 # optimize connection between modules anyhow = "1.0.57" pyo3 = "0.19" pyo3-log = "*" -serde = "1.0.143" +serde = "1.0.186" serde_json = "1.0.83" serde_yaml = "0.9.22" +serde_derive = "1.0.186" + diff --git a/rust/fastsim-cli/Cargo.toml b/rust/fastsim-cli/Cargo.toml index d734c2b0..7b55770e 100644 --- a/rust/fastsim-cli/Cargo.toml +++ b/rust/fastsim-cli/Cargo.toml @@ -14,6 +14,7 @@ repository = "https://github.com/NREL/fastsim" fastsim-core = { path = "../fastsim-core", version = "~0" } serde = { workspace = true } serde_json = { workspace = true } +serde_derive = { workspace = true } project-root = "0.2.2" clap = { version = "3.2.6", features = ["derive"] } regex = "1" diff --git a/rust/fastsim-cli/src/bin/fastsim-cli.rs b/rust/fastsim-cli/src/bin/fastsim-cli.rs index 4dc31237..7a7f5b30 100644 --- a/rust/fastsim-cli/src/bin/fastsim-cli.rs +++ b/rust/fastsim-cli/src/bin/fastsim-cli.rs @@ -1,5 +1,5 @@ use clap::{ArgGroup, Parser}; -use serde::{Deserialize, Serialize}; +use serde_derive::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::fs; diff --git a/rust/fastsim-core/Cargo.toml b/rust/fastsim-core/Cargo.toml index 53c6442a..d2ab41e2 100644 --- a/rust/fastsim-core/Cargo.toml +++ b/rust/fastsim-core/Cargo.toml @@ -16,7 +16,8 @@ pyo3 = { workspace = true, features = [ "anyhow", ], optional = true } anyhow = { workspace = true } -serde = { workspace = true, features = ["derive"] } +serde = { workspace = true } +serde_derive = { workspace = true } serde_yaml = { workspace = true } ndarray = { version = "0.15.4", features = ["serde"] } csv = "1.1" diff --git a/rust/fastsim-core/src/imports.rs b/rust/fastsim-core/src/imports.rs index 3317cf10..bbe5e7b1 100644 --- a/rust/fastsim-core/src/imports.rs +++ b/rust/fastsim-core/src/imports.rs @@ -2,7 +2,7 @@ pub(crate) use anyhow::{anyhow, bail, ensure}; pub(crate) use bincode::{deserialize, serialize}; pub(crate) use log; pub(crate) use ndarray::{array, concatenate, s, Array, Array1, Axis}; -pub(crate) use serde::{Deserialize, Serialize}; +pub(crate) use serde_derive::{Deserialize, Serialize}; pub(crate) use std::cmp; pub(crate) use std::ffi::OsStr; pub(crate) use std::fs::File; @@ -10,4 +10,3 @@ pub(crate) use std::path::{Path, PathBuf}; pub(crate) use crate::traits::*; pub(crate) use crate::utils::*; - diff --git a/rust/fastsim-core/src/simdrivelabel.rs b/rust/fastsim-core/src/simdrivelabel.rs index 4515a598..abc73c32 100644 --- a/rust/fastsim-core/src/simdrivelabel.rs +++ b/rust/fastsim-core/src/simdrivelabel.rs @@ -1,7 +1,7 @@ //! Module containing classes and methods for calculating label fuel economy. use ndarray::Array; -use serde::Serialize; +use serde_derive::Serialize; use std::collections::HashMap; // crate local diff --git a/rust/fastsim-core/src/traits.rs b/rust/fastsim-core/src/traits.rs index 0507a66b..ad55d557 100644 --- a/rust/fastsim-core/src/traits.rs +++ b/rust/fastsim-core/src/traits.rs @@ -1,7 +1,7 @@ use crate::imports::*; use std::collections::HashMap; -pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { +pub trait SerdeAPI: serde::Serialize + for<'a> serde::Deserialize<'a> { /// runs any initialization steps that might be needed fn init(&mut self) -> anyhow::Result<()> { Ok(()) @@ -45,7 +45,7 @@ pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { fn from_file(filename: &str) -> Result where Self: std::marker::Sized, - for<'de> Self: Deserialize<'de>, + for<'de> Self: serde::Deserialize<'de>, { let extension = Path::new(filename) .extension()