Skip to content

CI: Use cargo 1.84 feature to check MSRV #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 38 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.75.0
- uses: dtolnay/rust-toolchain@1.88.0
with:
components: clippy
- name: Update Cargo.lock
run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
- name: Check Clippy lints (reqwest)
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --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 serde,derive,hyper-client -- -D warnings
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings

# this checks that the code is formatted with rustfmt
rustfmt:
Expand All @@ -44,20 +46,6 @@ jobs:
- name: Check code formatting
run: cargo fmt --all -- --check

# this checks the msrv
msrv:
name: Verify MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: baptiste0928/cargo-install@v3
with:
crate: cargo-msrv
- name: Verify minimum rust version of influxdb crate
run: cargo msrv --path influxdb --output-format json verify
- name: Verify minimum rust version of influxdb_derive crate
run: cargo msrv --path influxdb_derive --output-format json verify

# this tests that all unit and doc tests are successful
unit_tests:
name: Unit and Doc Tests (Rust ${{matrix.rust.name}} on ${{matrix.os}})
Expand All @@ -77,21 +65,51 @@ jobs:
toolchain: nightly
nightly: true
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- rust:
name: MSRV
toolchain: stable
nightly: false
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust.toolchain}}
id: rust-toolchain
- run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
# on msrv runs, downgrade rust after generating the Cargo.lock file
- run: sudo apt -y update && sudo apt -y install --no-install-recommends yq
if: matrix.rust.name == 'MSRV'
- run: echo "rust-version=$(tomlq -r '.workspace.package."rust-version"' Cargo.toml)" >>$GITHUB_OUTPUT
id: msrv
if: matrix.rust.name == 'MSRV'
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{steps.msrv.outputs.rust-version}}
id: msrv-toolchain
if: matrix.rust.name == 'MSRV'
# on non-msrv runs, use one cache key ...
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
if: matrix.rust.name != 'MSRV'
# ... and on msrv runs, use another
- uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
target
key: "${{matrix.rust.toolchain}} on ${{runner.os}} Rust ${{steps.rust-toolchain.outputs.cachekey}}"
- run: cargo test --lib
- run: cargo test --doc
key: "${{runner.os}} Rust ${{steps.msrv-toolchain.outputs.cachekey}}"
if: matrix.rust.name == 'MSRV'
# finally we can run tests
- run: cargo test --lib --locked
- run: cargo test --doc --locked

# this tests that all integration tests are successful
integration_tests:
Expand Down
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

[workspace]
members = ["influxdb", "influxdb_derive", "benches"]
resolver = "2"

[workspace.package]
authors = ["Gero Gerke <[email protected]>", "Dominic <[email protected]>"]
edition = "2018"
rust-version = "1.65"
license = "MIT"
repository = "https://github.com/influxdb-rs/influxdb-rust"

[workspace.lints.rust]
bare_trait_objects = "forbid"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)', 'cfg(tarpaulin_include)'] }

[workspace.lints.clippy]
multiple_bound_locations = "allow" # clippy has wrong opinions
needless_doctest_main = "allow"
needless_lifetimes = "allow" # False positive in client/mod.rs query fn

[patch.crates-io]
influxdb = { path = "./influxdb" }
Expand Down
4 changes: 2 additions & 2 deletions README.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<a href="https://www.rust-lang.org/en-US/">
<img src="https://img.shields.io/badge/Made%20with-Rust-orange.svg" alt='Build with Rust' />
</a>
<a href="https://blog.rust-lang.org/2022/11/03/Rust-1.67.0.html">
<img src="https://img.shields.io/badge/rustc-1.67+-yellow.svg" alt='Minimum Rust Version: 1.67' />
<a href="https://github.com/rust-lang/rust/releases/tag/{{ rust_version | urlencode }}">
<img src="https://img.shields.io/badge/rustc-{{ rust_version | urlencode }}+-yellow.svg" alt='Minimum Rust Version: {{ rust_version }}' />
</a>
</p>

Expand Down
128 changes: 56 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,36 @@
<a href="https://www.rust-lang.org/en-US/">
<img src="https://img.shields.io/badge/Made%20with-Rust-orange.svg" alt='Build with Rust' />
</a>
<a href="https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html">
<img src="https://img.shields.io/badge/rustc-1.65+-yellow.svg" alt='Minimum Rust Version: 1.65' />
<a href="https://github.com/rust-lang/rust/releases/tag/1.65.0">
<img src="https://img.shields.io/badge/rustc-1.65.0+-yellow.svg" alt='Minimum Rust Version: 1.65.0' />
</a>
</p>

Pull requests are always welcome. See [Contributing][__link0] and [Code of Conduct][__link1]. For a list of past changes, see [CHANGELOG.md][__link2].


### Currently Supported Features

- Reading and writing to InfluxDB
- Optional Serde support for deserialization
- Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
- Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
- Authenticated and unauthenticated connections
- `async`/`await` support
- `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
- `GROUP BY` support
- Tokio and async-std support (see example below) or [available backends][__link3]
- Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))

* Reading and writing to InfluxDB
* Optional Serde support for deserialization
* Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
* Writing single or multiple measurements in one request (e.g. `WriteQuery` or `Vec<WriteQuery>` argument)
* Authenticated and unauthenticated connections
* `async`/`await` support
* `#[derive(InfluxDbWriteable)]` derive macro for writing / reading into structs
* `GROUP BY` support
* Tokio and async-std support (see example below) or [available backends][__link3]
* Swappable HTTP backends ([see below](#Choice-of-HTTP-backend))

## Quickstart

Add the following to your `Cargo.toml`


```toml
influxdb = { version = "0.7.2", features = ["derive"] }
```

For an example with using Serde deserialization, please refer to [serde_integration][__link4]


```rust
use chrono::{DateTime, Utc};
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};
Expand Down Expand Up @@ -104,73 +100,62 @@ async fn main() -> Result<(), Error> {
}
```

For further examples, check out the integration tests in `tests/integration_tests.rs` in the repository.

For further examples, check out the integration tests in `tests/integration_tests.rs`
in the repository.

## Choice of HTTP backend

To communicate with InfluxDB, you can choose the HTTP backend to be used configuring the appropriate feature. We recommend sticking with the default reqwest-based client, unless you really need async-std compatibility.

- **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
```toml
influxdb = { version = "0.7.2", features = ["derive"] }
```


- **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
```toml
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", "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", "serde", "hyper-client"] }
```


- **[curl][__link10]**, using [libcurl][__link11]
```toml
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", "serde", "h1-client"] }
```


- **[async-h1][__link13]** with [rustls][__link14]
```toml
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", "serde", "wasm-client"] }
```



* **[hyper][__link5]** (through reqwest, used by default), with [rustls][__link6]
```toml
influxdb = { version = "0.7.2", features = ["derive"] }
```

* **[hyper][__link7]** (through reqwest), with native TLS (OpenSSL)
```toml
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", "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", "serde", "hyper-client"] }
```

* **[curl][__link10]**, using [libcurl][__link11]
```toml
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", "serde", "h1-client"] }
```

* **[async-h1][__link13]** with [rustls][__link14]
```toml
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", "serde", "wasm-client"] }
```

## License

[![License: MIT][__link16]][__link17]

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][__link16]


@ 2020-2024 Gero Gerke, msrd0 and [contributors].

[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG_RDmlyxxvyrG0rwcLBKoYdvG5It9hbWNgjUGzjD8iBYfsFFYXKEG1LaAVLASZMqG5J2qfpyCvbMG_Rohh5BobOmG0DqLv5454SZYWSBgmhpbmZsdXhkYmUwLjcuMg
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG1LaAVLASZMqG5J2qfpyCvbMG_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 All @@ -179,8 +164,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
[__link13]: https://github.com/http-rs/async-h1
[__link14]: https://github.com/ctz/rustls
[__link15]: https://github.com/rustwasm/wasm-bindgen
[__link16]: https://img.shields.io/badge/License-MIT-yellow.svg
[__link17]: https://opensource.org/licenses/MIT
[__link16]: https://opensource.org/licenses/MIT
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
[__link3]: https://github.com/influxdb-rs/influxdb-rust/blob/main/influxdb/Cargo.toml
[__link4]: https://docs.rs/influxdb/0.7.2/influxdb/?search=integrations::serde_integration
Expand Down
13 changes: 8 additions & 5 deletions influxdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
[package]
name = "influxdb"
version = "0.7.2"
authors = ["Gero Gerke <[email protected]>"]
edition = "2018"
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "InfluxDB Driver for Rust"
keywords = ["influxdb", "database", "influx"]
license = "MIT"
license.workspace = true
readme = "README.md"
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
repository = "https://github.com/influxdb-rs/influxdb-rust"
rust-version = "1.70"
repository.workspace = true

[lints]
workspace = true

[dependencies]
chrono = { version = "0.4.23", features = ["serde"], default-features = false }
Expand Down
10 changes: 5 additions & 5 deletions influxdb/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Client {
.send()
.await
.map_err(|err| Error::ProtocolError {
error: format!("{}", err),
error: err.to_string(),
})?;

const BUILD_HEADER: &str = "X-Influxdb-Build";
Expand Down Expand Up @@ -276,13 +276,13 @@ impl Client {
let body = res.body_string();

let s = body.await.map_err(|_| Error::DeserializationError {
error: "response could not be converted to UTF-8".to_string(),
error: "response could not be converted to UTF-8".into(),
})?;

// todo: improve error parsing without serde
if s.contains("\"error\"") || s.contains("\"Error\"") {
return Err(Error::DatabaseError {
error: format!("influxdb error: \"{}\"", s),
error: format!("influxdb error: {s:?}"),
});
}

Expand All @@ -291,7 +291,7 @@ impl Client {

fn auth_if_needed(&self, rb: RequestBuilder) -> RequestBuilder {
if let Some(ref token) = self.token {
rb.header("Authorization", format!("Token {}", token))
rb.header("Authorization", format!("Token {token}"))
} else {
rb
}
Expand All @@ -314,7 +314,7 @@ mod tests {
#[test]
fn test_client_debug_redacted_password() {
let client = Client::new("https://localhost:8086", "db").with_auth("user", "pass");
let actual = format!("{:#?}", client);
let actual = format!("{client:#?}");
let expected = indoc! { r#"
Client {
url: "https://localhost:8086",
Expand Down
Loading
Loading