diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4acf827..1865d31 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,8 +5,8 @@ ### Checklist - [ ] Formatted code using `cargo fmt --all` - [ ] Linted code using clippy - - [ ] with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,reqwest-client-rustls -- -D warnings` - - [ ] with surf feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,hyper-client -- -D warnings` + - [ ] with reqwest feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings` + - [ ] with surf feature: `cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings` - [ ] Updated README.md using `cargo doc2readme -p influxdb --expand-macros` - [ ] Reviewed the diff. Did you leave any print statements or unnecessary comments? - [ ] Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 44fb04c..217688e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -28,9 +28,9 @@ jobs: with: components: clippy - name: Check Clippy lints (reqwest) - run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,reqwest-client-rustls -- -D warnings + run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings - name: Check Clippy lints (surf) - run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,hyper-client -- -D warnings + run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings # this checks that the code is formatted with rustfmt rustfmt: @@ -145,7 +145,7 @@ jobs: run: | for test in integration_tests{,_v2} do - cargo test -p influxdb --no-default-features --features 'use-serde derive ${{matrix.http-backend}}' --no-fail-fast --test $test + cargo test -p influxdb --no-default-features --features 'serde derive ${{matrix.http-backend}}' --no-fail-fast --test $test done # this uses cargo-tarpaulin to inspect the code coverage @@ -192,7 +192,7 @@ jobs: cargo tarpaulin -v \ --target-dir target/tarpaulin \ --workspace \ - --features use-serde,derive \ + --features serde,derive \ --exclude-files 'derive/*' \ --exclude-files 'target/*' \ --ignore-panics --ignore-tests \ diff --git a/README.md b/README.md index 95235d4..9865904 100644 --- a/README.md +++ b/README.md @@ -119,43 +119,43 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu - **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL) ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "reqwest-client-native-tls"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] } ``` - **[hyper][__link8]** (through reqwest), with vendored native TLS (OpenSSL) ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "reqwest-client-native-tls-vendored"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] } ``` - **[hyper][__link9]** (through surf), use this if you need tokio 0.2 compatibility ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "hyper-client"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] } ``` - **[curl][__link10]**, using [libcurl][__link11] ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "curl-client"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] } ``` - **[async-h1][__link12]** with native TLS (OpenSSL) ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "h1-client"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] } ``` - **[async-h1][__link13]** with [rustls][__link14] ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "h1-client-rustls"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] } ``` - WebAssembly’s `window.fetch`, via `web-sys` and **[wasm-bindgen][__link15]** ```toml - influxdb = { version = "0.7.2", default-features = false, features = ["derive", "use-serde", "wasm-client"] } + influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] } ``` @@ -170,7 +170,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu @ 2020-2024 Gero Gerke, msrd0 and [contributors]. [contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors - [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG_RDmlyxxvyrG0rwcLBKoYdvG5It9hbWNgjUGzjD8iBYfsFFYXKEG1DulEn7euxHG8tYaxMHih9OG3Xjpd76jUgIG23kKLUzm3NrYWSBgmhpbmZsdXhkYmUwLjcuMg + [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG_RDmlyxxvyrG0rwcLBKoYdvG5It9hbWNgjUGzjD8iBYfsFFYXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg [__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md [__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md [__link10]: https://github.com/alexcrichton/curl-rust diff --git a/influxdb/Cargo.toml b/influxdb/Cargo.toml index cc8ad20..1f2899b 100644 --- a/influxdb/Cargo.toml +++ b/influxdb/Cargo.toml @@ -21,14 +21,15 @@ lazy_static = "1.4.0" regex = "1.3.5" reqwest = { version = "0.11.4", default-features = false, optional = true } surf = { version = "2.2.0", default-features = false, optional = true } -serde = { version = "1.0.104", features = ["derive"], optional = true } +serde = { version = "1.0.186", optional = true } +serde_derive = { version = "1.0.186", optional = true } serde_json = { version = "1.0.48", optional = true } thiserror = "1.0" [features] -default = ["use-serde", "reqwest-client-rustls"] -derive = ["influxdb_derive"] -use-serde = ["serde", "serde_json"] +default = ["serde", "reqwest-client-rustls"] +derive = ["dep:influxdb_derive"] +serde = ["dep:serde", "dep:serde_derive", "dep:serde_json"] # http clients curl-client = ["surf", "surf/curl-client"] diff --git a/influxdb/src/integrations/serde_integration/de.rs b/influxdb/src/integrations/serde_integration/de.rs index 82eb607..a3e904d 100644 --- a/influxdb/src/integrations/serde_integration/de.rs +++ b/influxdb/src/integrations/serde_integration/de.rs @@ -1,8 +1,9 @@ use super::{Series, TaggedSeries}; use serde::de::{ - value, DeserializeSeed, Deserializer, Error, IntoDeserializer, MapAccess, SeqAccess, Visitor, + value, Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, MapAccess, + SeqAccess, Visitor, }; -use serde::Deserialize; +use serde_derive::Deserialize; use std::fmt; use std::marker::PhantomData; @@ -416,7 +417,7 @@ mod tests { #[test] fn test_deserialize_borrowed() { - use serde::Deserialize; + use serde_derive::Deserialize; // Deserializing a string that cannot be passed through // without escaping will result in an error like this: diff --git a/influxdb/src/integrations/serde_integration/mod.rs b/influxdb/src/integrations/serde_integration/mod.rs index 974853e..75b678b 100644 --- a/influxdb/src/integrations/serde_integration/mod.rs +++ b/influxdb/src/integrations/serde_integration/mod.rs @@ -8,7 +8,7 @@ //! //! ```rust,no_run //! use influxdb::{Client, Query}; -//! use serde::Deserialize; +//! use serde_derive::Deserialize; //! //! #[derive(Deserialize)] //! struct WeatherWithoutCityName { @@ -47,7 +47,8 @@ mod de; -use serde::{de::DeserializeOwned, Deserialize}; +use serde::de::DeserializeOwned; +use serde_derive::Deserialize; use crate::{client::check_status, Client, Error, Query, ReadQuery}; diff --git a/influxdb/src/lib.rs b/influxdb/src/lib.rs index 5bf74a6..d062e25 100644 --- a/influxdb/src/lib.rs +++ b/influxdb/src/lib.rs @@ -76,19 +76,19 @@ //! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest, used by default), with [rustls](https://github.com/ctz/rustls) #![doc = cargo_toml!(indent="\t", "derive")] //! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest), with native TLS (OpenSSL) -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "reqwest-client-native-tls")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls")] //! - **[hyper](https://github.com/hyperium/hyper)** (through reqwest), with vendored native TLS (OpenSSL) -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "reqwest-client-native-tls-vendored")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "reqwest-client-native-tls-vendored")] //! - **[hyper](https://github.com/hyperium/hyper)** (through surf), use this if you need tokio 0.2 compatibility -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "hyper-client")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "hyper-client")] //! - **[curl](https://github.com/alexcrichton/curl-rust)**, using [libcurl](https://curl.se/libcurl/) -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "curl-client")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "curl-client")] //! - **[async-h1](https://github.com/http-rs/async-h1)** with native TLS (OpenSSL) -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "h1-client")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "h1-client")] //! - **[async-h1](https://github.com/http-rs/async-h1)** with [rustls](https://github.com/ctz/rustls) -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "h1-client-rustls")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "h1-client-rustls")] //! - WebAssembly's `window.fetch`, via `web-sys` and **[wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)** -#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "use-serde", "wasm-client")] +#![doc = cargo_toml!(indent="\t", default-features = false, "derive", "serde", "wasm-client")] //! //! # License //! @@ -148,8 +148,8 @@ pub use query::{ InfluxDbWriteable, Query, QueryType, Timestamp, ValidQuery, }; -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] pub mod integrations { - #[cfg(feature = "use-serde")] + #[cfg(feature = "serde")] pub mod serde_integration; } diff --git a/influxdb/tests/derive_integration_tests.rs b/influxdb/tests/derive_integration_tests.rs index 7167aa6..1601ce7 100644 --- a/influxdb/tests/derive_integration_tests.rs +++ b/influxdb/tests/derive_integration_tests.rs @@ -7,8 +7,8 @@ use influxdb::InfluxDbWriteable; use chrono::{DateTime, Utc}; use influxdb::{Query, ReadQuery, Timestamp}; -#[cfg(feature = "use-serde")] -use serde::Deserialize; +#[cfg(feature = "serde")] +use serde_derive::Deserialize; use utilities::{assert_result_ok, create_client, create_db, delete_db, run_test}; @@ -24,7 +24,7 @@ struct WeatherReading { } #[derive(Debug)] -#[cfg_attr(feature = "use-serde", derive(Deserialize))] +#[cfg_attr(feature = "serde", derive(Deserialize))] struct WeatherReadingWithoutIgnored { time: DateTime, pressure: i32, @@ -81,7 +81,7 @@ async fn test_derive_simple_write() { /// /// This integration tests that writing data and retrieving the data again is working #[cfg(feature = "derive")] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[async_std::test] #[cfg(not(tarpaulin_include))] async fn test_write_and_read_option() { diff --git a/influxdb/tests/integration_tests.rs b/influxdb/tests/integration_tests.rs index e3750cc..f392f95 100644 --- a/influxdb/tests/integration_tests.rs +++ b/influxdb/tests/integration_tests.rs @@ -3,7 +3,7 @@ extern crate influxdb; #[path = "./utilities.rs"] mod utilities; -use serde::Deserialize; +use serde_derive::Deserialize; use utilities::{ assert_result_err, assert_result_ok, create_client, create_db, delete_db, run_test, }; @@ -277,7 +277,7 @@ async fn test_write_and_read_field() { /// /// This test case tests the authentication on json reads #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_json_non_authed_read() { const TEST_NAME: &str = "test_json_non_authed_read"; @@ -322,7 +322,7 @@ async fn test_json_non_authed_read() { /// /// This test case tests the authentication on json reads #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_json_authed_read() { const TEST_NAME: &str = "test_json_authed_read"; @@ -359,11 +359,9 @@ async fn test_json_authed_read() { /// /// This integration tests that writing data and retrieving the data again is working #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_write_and_read_option() { - use serde::Deserialize; - const TEST_NAME: &str = "test_write_and_read_option"; run_test( @@ -420,11 +418,9 @@ async fn test_write_and_read_option() { /// This test case tests whether JSON can be decoded from a InfluxDB response and whether that JSON /// is equal to the data which was written to the database #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_json_query() { - use serde::Deserialize; - const TEST_NAME: &str = "test_json_query"; run_test( @@ -472,11 +468,9 @@ async fn test_json_query() { /// This test case tests whether the response to a GROUP BY can be parsed by /// deserialize_next_tagged into a tags struct #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_json_query_tagged() { - use serde::Deserialize; - const TEST_NAME: &str = "test_json_query_tagged"; run_test( @@ -538,12 +532,10 @@ async fn test_json_query_tagged() { /// (tested with tokio) #[tokio::test] #[cfg(all( - feature = "use-serde", + feature = "serde", not(any(tarpaulin_include, feature = "hyper-client")) ))] async fn test_json_query_vec() { - use serde::Deserialize; - const TEST_NAME: &str = "test_json_query_vec"; run_test( @@ -590,11 +582,9 @@ async fn test_json_query_vec() { /// /// This integration test tests whether using the wrong query method fails building the query #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_serde_multi_query() { - use serde::Deserialize; - const TEST_NAME: &str = "test_serde_multi_query"; run_test( @@ -666,7 +656,7 @@ async fn test_serde_multi_query() { /// /// This integration test tests whether using the wrong query method fails building the query #[async_std::test] -#[cfg(feature = "use-serde")] +#[cfg(feature = "serde")] #[cfg(not(tarpaulin_include))] async fn test_wrong_query_errors() { let client = create_client("test_name");