@@ -19,23 +19,22 @@ This project has been able to run properly, PR is welcome.
19
19
20
20
```
21
21
[dependencies]
22
- influx_db_client = "^0.3.6 "
22
+ influx_db_client = "^0.4.0 "
23
23
```
24
24
25
25
### http
26
26
27
27
``` Rust
28
- #[macro_use]
29
- extern crate influx_db_client;
30
-
31
- use influx_db_client :: { Client , Point , Points , Value , Precision } ;
28
+ use influx_db_client :: {
29
+ Client , Point , Points , Value , Precision , point, points
30
+ };
31
+ use tokio ;
32
32
33
33
fn main () {
34
34
// default with "http://127.0.0.1:8086", db with "test"
35
35
let client = Client :: default (). set_authentication (" root" , " root" );
36
36
37
- let mut point = point! (" test1" );
38
- point
37
+ let point = point! (" test1" )
39
38
. add_field (" foo" , Value :: String (" bar" . to_string ()))
40
39
. add_field (" integer" , Value :: Integer (11 ))
41
40
. add_field (" float" , Value :: Float (22.3 ))
@@ -47,37 +46,34 @@ fn main() {
47
46
. add_tag (" float" , Value :: Float (12.6 ))
48
47
. add_field (" fd" , Value :: String (" '3'" . to_string ()))
49
48
. add_field (" quto" , Value :: String (" \ \\ " fda" . to_string ()))
50
- . add_field (" quto1" , Value :: String (" \ " fda" . to_string ()))
51
- . to_owned ();
49
+ . add_field (" quto1" , Value :: String (" \ " fda" . to_string ()));
52
50
53
51
let points = points! (point1 , point );
54
52
55
- // if Precision is None, the default is second
56
- // Multiple write
57
- let _ = client . write_points (points , Some (Precision :: Seconds ), None ). unwrap ();
53
+ tokio :: runtime :: Runtime :: new (). unwrap (). block_on (async move {
54
+ // if Precision is None, the default is second
55
+ // Multiple write
56
+ client . write_points (points , Some (Precision :: Seconds ), None ). await . unwrap ();
58
57
59
- // query, it's type is Option<Vec<Node>>
60
- let res = client . query (" select * from test1" , None ). unwrap ();
61
- println! (" {:?}" , res . unwrap ()[0 ]. series)
58
+ // query, it's type is Option<Vec<Node>>
59
+ let res = client . query (" select * from test1" , None ). await . unwrap ();
60
+ println! (" {:?}" , res . unwrap ()[0 ]. series)
61
+ });
62
62
}
63
63
```
64
64
65
65
### udp
66
66
67
67
``` Rust
68
- #[macro_use]
69
- extern crate influx_db_client;
70
-
71
- use influx_db_client :: {UdpClient , Point , Value };
68
+ use influx_db_client :: {UdpClient , Point , Value , point};
72
69
73
70
fn main () {
74
71
let mut udp = UdpClient :: new (" 127.0.0.1:8089" );
75
72
udp . add_host (" 127.0.0.1:8090" );
76
73
77
- let mut point = point! (" test" );
78
- point . add_field (" foo" , Value :: String (String :: from (" bar" )));
74
+ let point = point! (" test" ). add_field (" foo" , Value :: String (String :: from (" bar" )));
79
75
80
- let _ = udp . write_point (point ). unwrap ();
76
+ udp . write_point (point ). unwrap ();
81
77
}
82
78
```
83
79
0 commit comments