@@ -62,48 +62,47 @@ For an example with using Serde deserialization, please refer to [serde_integrat
6262
6363
6464``` rust
65- use influxdb :: {Client , Query , Timestamp , ReadQuery };
66- use influxdb :: InfluxDbWriteable ;
6765use chrono :: {DateTime , Utc };
66+ use influxdb :: {Client , Error , InfluxDbWriteable , ReadQuery , Timestamp };
6867
6968#[tokio:: main]
7069// or #[async_std::main] if you prefer
71- async fn main () {
70+ async fn main () -> Result <(), Error > {
7271 // Connect to db `test` on `http://localhost:8086`
7372 let client = Client :: new (" http://localhost:8086" , " test" );
7473
7574 #[derive(InfluxDbWriteable )]
7675 struct WeatherReading {
7776 time : DateTime <Utc >,
7877 humidity : i32 ,
79- #[influxdb(tag)] wind_direction : String ,
78+ #[influxdb(tag)]
79+ wind_direction : String ,
8080 }
8181
8282 // Let's write some data into a measurement called `weather`
83- let weather_readings = vec! (
83+ let weather_readings = vec! [
8484 WeatherReading {
8585 time : Timestamp :: Hours (1 ). into (),
8686 humidity : 30 ,
8787 wind_direction : String :: from (" north" ),
88- }. into_query (" weather" ),
88+ }
89+ . into_query (" weather" ),
8990 WeatherReading {
9091 time : Timestamp :: Hours (2 ). into (),
9192 humidity : 40 ,
9293 wind_direction : String :: from (" west" ),
93- }. into_query (" weather" ),
94- );
94+ }
95+ . into_query (" weather" ),
96+ ];
9597
96- let write_result = client
97- . query (weather_readings )
98- . await ;
99- assert! (write_result . is_ok (), " Write result was not okay" );
98+ client . query (weather_readings ). await ? ;
10099
101100 // Let's see if the data we wrote is there
102101 let read_query = ReadQuery :: new (" SELECT * FROM weather" );
103102
104- let read_result = client . query (read_query ). await ;
105- assert! ( read_result . is_ok (), " Read result was not ok " );
106- println! ( " {} " , read_result . unwrap ());
103+ let read_result = client . query (read_query ). await ? ;
104+ println! ( " {} " , read_result );
105+ Ok ( ())
107106}
108107```
109108
@@ -167,7 +166,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
167166@ 2020 Gero Gerke and [ contributors] .
168167
169168 [ contributors ] : https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
170- [ __cargo_doc2readme_dependencies_info ] : ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG8qCijK3OhAgG9r5dMb74ZyFGy-UgqMKZw5_G6wZmUfHdMJDYWSBgmhpbmZsdXhkYmUwLjcuMQ
169+ [ __cargo_doc2readme_dependencies_info ] : ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEGzTIyZ81-O7yGzBPOAorSf5GGwJWIVB6K85jG41Hl-f5lXJVYWSBgmhpbmZsdXhkYmUwLjcuMQ
171170 [ __link0 ] : https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
172171 [ __link1 ] : https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
173172 [ __link10 ] : https://curl.se/libcurl/
0 commit comments