Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolver = "2"
[workspace.package]
authors = ["Gero Gerke <git@gero.dev>", "Dominic <git@msrd0.de>"]
edition = "2021"
rust-version = "1.67.1"
rust-version = "1.70"
license = "MIT"
repository = "https://github.com/influxdb-rs/influxdb-rust"

Expand Down
16 changes: 9 additions & 7 deletions README.md
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://github.com/rust-lang/rust/releases/tag/1.67.1">
<img src="https://img.shields.io/badge/rustc-1.67.1+-yellow.svg" alt='Minimum Rust Version: 1.67.1' />
<a href="https://github.com/rust-lang/rust/releases/tag/1.70.0">
<img src="https://img.shields.io/badge/rustc-1.70.0+-yellow.svg" alt='Minimum Rust Version: 1.70.0' />
</a>
</p>

Expand Down Expand Up @@ -75,17 +75,19 @@ async fn main() -> Result<(), Error> {
// Let's write some data into a measurement called `weather`
let weather_readings = vec![
WeatherReading {
time: Timestamp::Hours(1).into(),
time: Timestamp::Hours(1).try_into().unwrap(),
humidity: 30,
wind_direction: String::from("north"),
}
.into_query("weather"),
.try_into_query("weather")
.unwrap(),
WeatherReading {
time: Timestamp::Hours(2).into(),
time: Timestamp::Hours(2).try_into().unwrap(),
humidity: 40,
wind_direction: String::from("west"),
}
.into_query("weather"),
.try_into_query("weather")
.unwrap(),
];

client.query(weather_readings).await?;
Expand Down Expand Up @@ -129,7 +131,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]: ggGkYW0CYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG8LHWNBBuXgSGz-2Lrx4E_kTG0bJiXb6A8zNG9GhXhvU8L0xYWSBgmhpbmZsdXhkYmUwLjcuMg
[__cargo_doc2readme_dependencies_info]: ggGkYW0CYXSEGzJ_QpW55zB1G0S-TER-rIfLG2gXv8EYBG3jG1nuXXn-kdx-YXKEG5esg8JWCUnDGygXCh47ngu0G4kPgAyV809_G2pbKPyN9jeVYWSBgmhpbmZsdXhkYmUwLjcuMg
[__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
[__link2]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CHANGELOG.md
Expand Down
4 changes: 1 addition & 3 deletions benches/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use chrono::{DateTime, Utc};
use influxdb::Error;
use influxdb::InfluxDbWriteable;
use influxdb::{Client, ReadQuery};
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery};
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::mpsc::unbounded_channel;
Expand Down
15 changes: 7 additions & 8 deletions influxdb/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use std::fmt::{self, Debug, Formatter};
use std::sync::Arc;

use crate::query::QueryType;
use crate::Error;
use crate::Query;
use crate::{Error, Query};

#[derive(Clone)]
/// Internal Representation of a Client
Expand Down Expand Up @@ -188,21 +187,21 @@ impl Client {
/// # Examples
///
/// ```rust,no_run
/// use influxdb::{Client, Query, Timestamp};
/// use influxdb::InfluxDbWriteable;
/// use influxdb::{Client, InfluxDbWriteable, Query, Timestamp};
/// use std::time::{SystemTime, UNIX_EPOCH};
///
/// # #[tokio::main]
/// # async fn main() -> Result<(), influxdb::Error> {
/// let start = SystemTime::now();
/// let since_the_epoch = start
/// .duration_since(UNIX_EPOCH)
/// .expect("Time went backwards")
/// .as_millis();
/// .duration_since(UNIX_EPOCH)
/// .expect("Time went backwards")
/// .as_millis();
///
/// let client = Client::new("http://localhost:8086", "test");
/// let query = Timestamp::Milliseconds(since_the_epoch)
/// .into_query("weather")
/// .try_into_query("weather")
/// .unwrap()
/// .add_field("temperature", 82);
/// let results = client.query(query).await?;
///
Expand Down
12 changes: 12 additions & 0 deletions influxdb/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ pub enum Error {
/// Error happens when HTTP request fails
ConnectionError { error: String },
}

#[cfg(feature = "chrono")]
#[derive(Clone, Copy, Debug, Error)]
#[error("The timestamp is too large to fit into an i64.")]
pub struct TimestampTooLargeError(pub(crate) ());

#[cfg(any(feature = "chrono", feature = "time"))]
#[derive(Clone, Copy, Debug, Error)]
pub enum TimeTryFromError<T, I> {
TimeError(#[source] T),
IntError(#[source] I),
}
6 changes: 3 additions & 3 deletions influxdb/src/integrations/serde_integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
//! .series
//! .into_iter()
//! .map(|mut city_series| {
//! let city_name =
//! city_series.name.split("_").collect::<Vec<&str>>().remove(2);
//! let city_name = city_series.name.split("_").collect::<Vec<&str>>().remove(2);
//! Weather {
//! weather: city_series.values.remove(0),
//! city_name: city_name.to_string(),
Expand All @@ -50,7 +49,8 @@ mod de;
use serde::de::DeserializeOwned;
use serde_derive::Deserialize;

use crate::{client::check_status, Client, Error, Query, ReadQuery};
use crate::client::check_status;
use crate::{Client, Error, Query, ReadQuery};

#[derive(Deserialize)]
#[doc(hidden)]
Expand Down
19 changes: 9 additions & 10 deletions influxdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//! # Quickstart
//!
//! Add the following to your `Cargo.toml`
//!
#![doc = cargo_toml!(indent="", "derive")]
//!
//! For an example with using Serde deserialization, please refer to [serde_integration](crate::integrations::serde_integration)
Expand All @@ -41,17 +40,19 @@
//! // Let's write some data into a measurement called `weather`
//! let weather_readings = vec![
//! WeatherReading {
//! time: Timestamp::Hours(1).into(),
//! time: Timestamp::Hours(1).try_into().unwrap(),
//! humidity: 30,
//! wind_direction: String::from("north"),
//! }
//! .into_query("weather"),
//! .try_into_query("weather")
//! .unwrap(),
//! WeatherReading {
//! time: Timestamp::Hours(2).into(),
//! time: Timestamp::Hours(2).try_into().unwrap(),
//! humidity: 40,
//! wind_direction: String::from("west"),
//! }
//! .into_query("weather"),
//! .try_into_query("weather")
//! .unwrap(),
//! ];
//!
//! client.query(weather_readings).await?;
Expand Down Expand Up @@ -123,11 +124,9 @@ mod query;

pub use client::Client;
pub use error::Error;
pub use query::{
read_query::ReadQuery,
write_query::{Type, WriteQuery},
InfluxDbWriteable, Query, QueryType, Timestamp, ValidQuery,
};
pub use query::read_query::ReadQuery;
pub use query::write_query::{Type, WriteQuery};
pub use query::{InfluxDbWriteable, Query, QueryType, Timestamp, ValidQuery};

#[cfg(feature = "serde")]
pub mod integrations {
Expand Down
Loading
Loading