From 31fc6d57d7f40f6ed30cb330ed8c153db56c3a8b Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Tue, 14 Nov 2023 13:19:55 +0100 Subject: [PATCH] README: run doc2readme --- README.md | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4259fdc..c05a00a 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,12 @@ For an example with using Serde deserialization, please refer to [serde_integrat ```rust -use influxdb::{Client, Timestamp, ReadQuery}; -use influxdb::InfluxDbWriteable; use chrono::{DateTime, Utc}; +use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp}; #[tokio::main] // or #[async_std::main] if you prefer -async fn main() { +async fn main() -> Result<(), Error> { // Connect to db `test` on `http://localhost:8086` let client = Client::new("http://localhost:8086", "test"); @@ -76,35 +75,34 @@ async fn main() { struct WeatherReading { time: DateTime, humidity: i32, - #[influxdb(tag)] wind_direction: String, + #[influxdb(tag)] + wind_direction: String, } // Let's write some data into a measurement called `weather` - let weather_readings = vec!( + let weather_readings = vec![ WeatherReading { time: Timestamp::Hours(1).into(), humidity: 30, wind_direction: String::from("north"), - }.into_query("weather"), + } + .into_query("weather"), WeatherReading { time: Timestamp::Hours(2).into(), humidity: 40, wind_direction: String::from("west"), - }.into_query("weather"), - ); + } + .into_query("weather"), + ]; - if let Err(e) = client.query(weather_readings).await { - println!("Error writing result: {e}"); - return; - } + client.query(weather_readings).await?; // Let's see if the data we wrote is there let read_query = ReadQuery::new("SELECT * FROM weather"); - match client.query(read_query).await { - Ok(read_result) => println!("{}", read_result), - Err(e) => println!("Error reading result: {e}"), - } + let read_result = client.query(read_query).await?; + println!("{}", read_result); + Ok(()) } ``` @@ -168,7 +166,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu @ 2020 Gero Gerke and [contributors]. [contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors - [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG_D2JHss1jsUG6eXkB7MmDoIG9miwB7MgvlwG_-cxCbQ3T7bYWSBgmhpbmZsdXhkYmUwLjcuMQ + [__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEGzTIyZ81-O7yGzBPOAorSf5GGwJWIVB6K85jG41Hl-f5lXJVYWSBgmhpbmZsdXhkYmUwLjcuMQ [__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://curl.se/libcurl/