@@ -62,48 +62,47 @@ For an example with using Serde deserialization, please refer to [serde_integrat
62
62
63
63
64
64
``` rust
65
- use influxdb :: {Client , Query , Timestamp , ReadQuery };
66
- use influxdb :: InfluxDbWriteable ;
67
65
use chrono :: {DateTime , Utc };
66
+ use influxdb :: {Client , Error , InfluxDbWriteable , ReadQuery , Timestamp };
68
67
69
68
#[tokio:: main]
70
69
// or #[async_std::main] if you prefer
71
- async fn main () {
70
+ async fn main () -> Result <(), Error > {
72
71
// Connect to db `test` on `http://localhost:8086`
73
72
let client = Client :: new (" http://localhost:8086" , " test" );
74
73
75
74
#[derive(InfluxDbWriteable )]
76
75
struct WeatherReading {
77
76
time : DateTime <Utc >,
78
77
humidity : i32 ,
79
- #[influxdb(tag)] wind_direction : String ,
78
+ #[influxdb(tag)]
79
+ wind_direction : String ,
80
80
}
81
81
82
82
// Let's write some data into a measurement called `weather`
83
- let weather_readings = vec! (
83
+ let weather_readings = vec! [
84
84
WeatherReading {
85
85
time : Timestamp :: Hours (1 ). into (),
86
86
humidity : 30 ,
87
87
wind_direction : String :: from (" north" ),
88
- }. into_query (" weather" ),
88
+ }
89
+ . into_query (" weather" ),
89
90
WeatherReading {
90
91
time : Timestamp :: Hours (2 ). into (),
91
92
humidity : 40 ,
92
93
wind_direction : String :: from (" west" ),
93
- }. into_query (" weather" ),
94
- );
94
+ }
95
+ . into_query (" weather" ),
96
+ ];
95
97
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 ? ;
100
99
101
100
// Let's see if the data we wrote is there
102
101
let read_query = ReadQuery :: new (" SELECT * FROM weather" );
103
102
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 ( ())
107
106
}
108
107
```
109
108
@@ -167,7 +166,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
167
166
@ 2020 Gero Gerke and [ contributors] .
168
167
169
168
[ 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
171
170
[ __link0 ] : https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
172
171
[ __link1 ] : https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
173
172
[ __link10 ] : https://curl.se/libcurl/
0 commit comments