Skip to content

Commit

Permalink
Rename use-serde feature into serde (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 authored Mar 7, 2024
1 parent 5622313 commit 40cc2aa
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
```


Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions influxdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
7 changes: 4 additions & 3 deletions influxdb/src/integrations/serde_integration/de.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions influxdb/src/integrations/serde_integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//!
//! ```rust,no_run
//! use influxdb::{Client, Query};
//! use serde::Deserialize;
//! use serde_derive::Deserialize;
//!
//! #[derive(Deserialize)]
//! struct WeatherWithoutCityName {
Expand Down Expand Up @@ -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};

Expand Down
18 changes: 9 additions & 9 deletions influxdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down Expand Up @@ -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;
}
8 changes: 4 additions & 4 deletions influxdb/tests/derive_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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<Utc>,
pressure: i32,
Expand Down Expand Up @@ -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() {
Expand Down
28 changes: 9 additions & 19 deletions influxdb/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 40cc2aa

Please sign in to comment.