Parcourir la source

Revert to tokio.

Mathias Gottschlag il y a 5 ans
Parent
révision
736b6d117f
4 fichiers modifiés avec 85 ajouts et 188 suppressions
  1. 56
    163
      Cargo.lock
  2. 5
    3
      Cargo.toml
  3. 7
    10
      src/bin/client.rs
  4. 17
    12
      src/bin/server.rs

+ 56
- 163
Cargo.lock Voir le fichier

@@ -26,47 +26,15 @@ name = "arrayvec"
26 26
 version = "0.5.1"
27 27
 source = "registry+https://github.com/rust-lang/crates.io-index"
28 28
 
29
-[[package]]
30
-name = "async-std"
31
-version = "1.4.0"
32
-source = "registry+https://github.com/rust-lang/crates.io-index"
33
-dependencies = [
34
- "async-task 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
35
- "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
36
- "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
37
- "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
38
- "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
39
- "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
40
- "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
41
- "kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
42
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
43
- "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
44
- "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
45
- "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
46
- "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
47
- "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
48
- "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
49
- "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)",
50
- "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
51
-]
52
-
53
-[[package]]
54
-name = "async-task"
55
-version = "1.1.1"
56
-source = "registry+https://github.com/rust-lang/crates.io-index"
57
-dependencies = [
58
- "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
59
-]
60
-
61 29
 [[package]]
62 30
 name = "async-tungstenite"
63 31
 version = "0.3.0"
64 32
 source = "registry+https://github.com/rust-lang/crates.io-index"
65 33
 dependencies = [
66
- "async-std 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
67 34
  "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
68 35
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
69 36
  "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
37
+ "tokio 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
70 38
  "tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
71 39
 ]
72 40
 
@@ -79,11 +47,6 @@ dependencies = [
79 47
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
80 48
 ]
81 49
 
82
-[[package]]
83
-name = "autocfg"
84
-version = "0.1.7"
85
-source = "registry+https://github.com/rust-lang/crates.io-index"
86
-
87 50
 [[package]]
88 51
 name = "backtrace"
89 52
 version = "0.3.40"
@@ -170,6 +133,11 @@ dependencies = [
170 133
  "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
171 134
 ]
172 135
 
136
+[[package]]
137
+name = "bytes"
138
+version = "0.5.3"
139
+source = "registry+https://github.com/rust-lang/crates.io-index"
140
+
173 141
 [[package]]
174 142
 name = "c2-chacha"
175 143
 version = "0.2.3"
@@ -215,36 +183,6 @@ name = "constant_time_eq"
215 183
 version = "0.1.4"
216 184
 source = "registry+https://github.com/rust-lang/crates.io-index"
217 185
 
218
-[[package]]
219
-name = "crossbeam-channel"
220
-version = "0.4.0"
221
-source = "registry+https://github.com/rust-lang/crates.io-index"
222
-dependencies = [
223
- "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
224
-]
225
-
226
-[[package]]
227
-name = "crossbeam-deque"
228
-version = "0.7.2"
229
-source = "registry+https://github.com/rust-lang/crates.io-index"
230
-dependencies = [
231
- "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
232
- "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
233
-]
234
-
235
-[[package]]
236
-name = "crossbeam-epoch"
237
-version = "0.8.0"
238
-source = "registry+https://github.com/rust-lang/crates.io-index"
239
-dependencies = [
240
- "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
241
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
242
- "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
243
- "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
244
- "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
245
- "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
246
-]
247
-
248 186
 [[package]]
249 187
 name = "crossbeam-utils"
250 188
 version = "0.6.6"
@@ -254,16 +192,6 @@ dependencies = [
254 192
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
255 193
 ]
256 194
 
257
-[[package]]
258
-name = "crossbeam-utils"
259
-version = "0.7.0"
260
-source = "registry+https://github.com/rust-lang/crates.io-index"
261
-dependencies = [
262
- "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
263
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
264
- "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
265
-]
266
-
267 195
 [[package]]
268 196
 name = "digest"
269 197
 version = "0.8.1"
@@ -422,9 +350,14 @@ version = "0.3.1"
422 350
 source = "registry+https://github.com/rust-lang/crates.io-index"
423 351
 
424 352
 [[package]]
425
-name = "futures-timer"
426
-version = "2.0.2"
427
-source = "registry+https://github.com/rust-lang/crates.io-index"
353
+name = "futures-tokio-compat"
354
+version = "0.1.0"
355
+source = "git+https://github.com/mgottschlag/futures-tokio-compat.git#b1cace55e11809e16e1fe83af308aff7629c792a"
356
+dependencies = [
357
+ "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
358
+ "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
359
+ "tokio 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
360
+]
428 361
 
429 362
 [[package]]
430 363
 name = "futures-util"
@@ -470,14 +403,6 @@ dependencies = [
470 403
  "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
471 404
 ]
472 405
 
473
-[[package]]
474
-name = "hermit-abi"
475
-version = "0.1.5"
476
-source = "registry+https://github.com/rust-lang/crates.io-index"
477
-dependencies = [
478
- "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
479
-]
480
-
481 406
 [[package]]
482 407
 name = "http"
483 408
 version = "0.1.21"
@@ -511,6 +436,14 @@ dependencies = [
511 436
  "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
512 437
 ]
513 438
 
439
+[[package]]
440
+name = "inotify-sys"
441
+version = "0.1.3"
442
+source = "registry+https://github.com/rust-lang/crates.io-index"
443
+dependencies = [
444
+ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
445
+]
446
+
514 447
 [[package]]
515 448
 name = "input_buffer"
516 449
 version = "0.2.0"
@@ -541,14 +474,6 @@ dependencies = [
541 474
  "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
542 475
 ]
543 476
 
544
-[[package]]
545
-name = "kv-log-macro"
546
-version = "1.0.4"
547
-source = "registry+https://github.com/rust-lang/crates.io-index"
548
-dependencies = [
549
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
550
-]
551
-
552 477
 [[package]]
553 478
 name = "lazy_static"
554 479
 version = "1.4.0"
@@ -577,14 +502,6 @@ name = "memchr"
577 502
 version = "2.2.1"
578 503
 source = "registry+https://github.com/rust-lang/crates.io-index"
579 504
 
580
-[[package]]
581
-name = "memoffset"
582
-version = "0.5.3"
583
-source = "registry+https://github.com/rust-lang/crates.io-index"
584
-dependencies = [
585
- "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
586
-]
587
-
588 505
 [[package]]
589 506
 name = "mio"
590 507
 version = "0.6.21"
@@ -634,20 +551,6 @@ dependencies = [
634 551
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
635 552
 ]
636 553
 
637
-[[package]]
638
-name = "num_cpus"
639
-version = "1.11.1"
640
-source = "registry+https://github.com/rust-lang/crates.io-index"
641
-dependencies = [
642
- "hermit-abi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
643
- "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
644
-]
645
-
646
-[[package]]
647
-name = "once_cell"
648
-version = "1.2.0"
649
-source = "registry+https://github.com/rust-lang/crates.io-index"
650
-
651 554
 [[package]]
652 555
 name = "opaque-debug"
653 556
 version = "0.2.3"
@@ -855,37 +758,11 @@ name = "rustc-demangle"
855 758
 version = "0.1.16"
856 759
 source = "registry+https://github.com/rust-lang/crates.io-index"
857 760
 
858
-[[package]]
859
-name = "rustc_version"
860
-version = "0.2.3"
861
-source = "registry+https://github.com/rust-lang/crates.io-index"
862
-dependencies = [
863
- "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
864
-]
865
-
866 761
 [[package]]
867 762
 name = "ryu"
868 763
 version = "1.0.2"
869 764
 source = "registry+https://github.com/rust-lang/crates.io-index"
870 765
 
871
-[[package]]
872
-name = "scopeguard"
873
-version = "1.0.0"
874
-source = "registry+https://github.com/rust-lang/crates.io-index"
875
-
876
-[[package]]
877
-name = "semver"
878
-version = "0.9.0"
879
-source = "registry+https://github.com/rust-lang/crates.io-index"
880
-dependencies = [
881
- "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
882
-]
883
-
884
-[[package]]
885
-name = "semver-parser"
886
-version = "0.7.0"
887
-source = "registry+https://github.com/rust-lang/crates.io-index"
888
-
889 766
 [[package]]
890 767
 name = "serde"
891 768
 version = "1.0.104"
@@ -1006,6 +883,32 @@ dependencies = [
1006 883
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1007 884
 ]
1008 885
 
886
+[[package]]
887
+name = "tokio"
888
+version = "0.2.9"
889
+source = "registry+https://github.com/rust-lang/crates.io-index"
890
+dependencies = [
891
+ "bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
892
+ "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
893
+ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
894
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
895
+ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
896
+ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
897
+ "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
898
+ "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
899
+ "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
900
+ "tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
901
+]
902
+
903
+[[package]]
904
+name = "tokio-macros"
905
+version = "0.2.3"
906
+source = "registry+https://github.com/rust-lang/crates.io-index"
907
+dependencies = [
908
+ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
909
+ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
910
+]
911
+
1009 912
 [[package]]
1010 913
 name = "tungstenite"
1011 914
 version = "0.9.2"
@@ -1028,17 +931,19 @@ dependencies = [
1028 931
 name = "twfss"
1029 932
 version = "0.1.0"
1030 933
 dependencies = [
1031
- "async-std 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1032 934
  "async-tungstenite 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
1033 935
  "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
1034 936
  "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1035 937
  "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
1036 938
  "fswatcher 0.1.0",
1037 939
  "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
940
+ "futures-tokio-compat 0.1.0 (git+https://github.com/mgottschlag/futures-tokio-compat.git)",
941
+ "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
1038 942
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1039 943
  "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
1040 944
  "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
1041 945
  "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
946
+ "tokio 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
1042 947
 ]
1043 948
 
1044 949
 [[package]]
@@ -1162,11 +1067,8 @@ dependencies = [
1162 1067
 "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
1163 1068
 "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
1164 1069
 "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
1165
-"checksum async-std 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bf6039b315300e057d198b9d3ab92ee029e31c759b7f1afae538145e6f18a3e"
1166
-"checksum async-task 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d22dc86693d375d2733b536fd8914bea0fa93adf4b1e6bcbd9c7c500cb62d920"
1167 1070
 "checksum async-tungstenite 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d35b7b512425d228d0366885b417ae3884930673ac1265764f1a8389dd2b00c4"
1168 1071
 "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
1169
-"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
1170 1072
 "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
1171 1073
 "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
1172 1074
 "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
@@ -1178,17 +1080,14 @@ dependencies = [
1178 1080
 "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
1179 1081
 "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
1180 1082
 "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
1083
+"checksum bytes 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38"
1181 1084
 "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
1182 1085
 "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76"
1183 1086
 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
1184 1087
 "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
1185 1088
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1186 1089
 "checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
1187
-"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c"
1188
-"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
1189
-"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac"
1190 1090
 "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
1191
-"checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4"
1192 1091
 "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
1193 1092
 "checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
1194 1093
 "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"
@@ -1208,33 +1107,29 @@ dependencies = [
1208 1107
 "checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764"
1209 1108
 "checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16"
1210 1109
 "checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9"
1211
-"checksum futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6"
1110
+"checksum futures-tokio-compat 0.1.0 (git+https://github.com/mgottschlag/futures-tokio-compat.git)" = "<none>"
1212 1111
 "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76"
1213 1112
 "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
1214 1113
 "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"
1215 1114
 "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
1216
-"checksum hermit-abi 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f629dc602392d3ec14bfc8a09b5e644d7ffd725102b48b81e59f90f2633621d7"
1217 1115
 "checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
1218 1116
 "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
1219 1117
 "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
1220 1118
 "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
1119
+"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
1221 1120
 "checksum input_buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e1b822cc844905551931d6f81608ed5f50a79c1078a4e2b4d42dbc7c1eedfbf"
1222 1121
 "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
1223 1122
 "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
1224 1123
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
1225
-"checksum kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb"
1226 1124
 "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
1227 1125
 "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
1228 1126
 "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
1229 1127
 "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
1230 1128
 "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
1231
-"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
1232 1129
 "checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
1233 1130
 "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125"
1234 1131
 "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
1235 1132
 "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
1236
-"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72"
1237
-"checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed"
1238 1133
 "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
1239 1134
 "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
1240 1135
 "checksum pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469"
@@ -1262,11 +1157,7 @@ dependencies = [
1262 1157
 "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
1263 1158
 "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf"
1264 1159
 "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
1265
-"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1266 1160
 "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
1267
-"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
1268
-"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
1269
-"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
1270 1161
 "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
1271 1162
 "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
1272 1163
 "checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7"
@@ -1281,6 +1172,8 @@ dependencies = [
1281 1172
 "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
1282 1173
 "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
1283 1174
 "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
1175
+"checksum tokio 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ffa2fdcfa937b20cb3c822a635ceecd5fc1a27a6a474527e5516aa24b8c8820a"
1176
+"checksum tokio-macros 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "50a61f268a3db2acee8dcab514efc813dc6dbe8a00e86076f935f94304b59a7a"
1284 1177
 "checksum tungstenite 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a0c2bd5aeb7dcd2bb32e472c8872759308495e5eccc942e929a513cd8d36110"
1285 1178
 "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
1286 1179
 "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"

+ 5
- 3
Cargo.toml Voir le fichier

@@ -11,8 +11,10 @@ serde = { version = "1.0", features = ["derive"] }
11 11
 serde_json = "1.0"
12 12
 dirs = "2.0"
13 13
 byteorder = "1.3"
14
-async-std = "1.0"
15
-async-tungstenite = { version = "0.3", features = ["async-std-runtime"] }
16
-futures = "0.3"
14
+tokio = { version = "0.2", features = ["fs", "io-util", "macros", "net", "stream", "tcp"] }
15
+futures = "0.3.1"
16
+futures-tokio-compat = { git = "https://github.com/mgottschlag/futures-tokio-compat.git" }
17
+async-tungstenite = { version = "0.3", features = ["tokio-runtime"] }
17 18
 env_logger = "0.7"
18 19
 log = "0.4"
20
+inotify-sys = "0.1"

+ 7
- 10
src/bin/client.rs Voir le fichier

@@ -2,9 +2,9 @@ use std::fs::create_dir_all;
2 2
 use std::io;
3 3
 use std::sync::{Arc, Mutex};
4 4
 
5
-use async_std::os::unix::net::{UnixListener, UnixStream};
6
-use async_std::prelude::*;
7
-use async_std::task;
5
+use tokio::net::{UnixListener, UnixStream};
6
+use tokio::stream::StreamExt;
7
+use tokio::io::{AsyncWriteExt, AsyncReadExt};
8 8
 
9 9
 use twfss::{Database, SynchronizedDirectory};
10 10
 
@@ -28,11 +28,8 @@ fn db_path() -> String {
28 28
     format!("{}/client.db", data_dir())
29 29
 }
30 30
 
31
-fn main() {
32
-    task::block_on(run());
33
-}
34
-
35
-async fn run() {
31
+#[tokio::main]
32
+async fn main() {
36 33
     // Create the data directories if necessary.
37 34
     create_dir_all(config_dir()).unwrap();
38 35
     create_dir_all(data_dir()).unwrap();
@@ -53,7 +50,7 @@ async fn run() {
53 50
 
54 51
     // Listen for CLI commands.
55 52
     // TODO: Graceful shutdown on errors.
56
-    let listener = UnixListener::bind(cli::socket_path()).await.unwrap();
53
+    let mut listener = UnixListener::bind(cli::socket_path()).unwrap();
57 54
     let mut incoming = listener.incoming();
58 55
     while let Some(stream) = incoming.next().await {
59 56
         match stream {
@@ -64,7 +61,7 @@ async fn run() {
64 61
                     Err(e) => {
65 62
                         // Log error and try to send it to the stream.
66 63
                         // TODO
67
-                        write!(stream, "Error: {:?}", e).await.ok();
64
+                        stream.write_all(format!("Error: {:?}", e).as_bytes()).await.ok();
68 65
                     }
69 66
                 };
70 67
             }

+ 17
- 12
src/bin/server.rs Voir le fichier

@@ -1,8 +1,11 @@
1
-use async_std::net::{SocketAddr, TcpListener, TcpStream};
2
-use async_std::task;
1
+use std::net::SocketAddr;
2
+
3 3
 use async_tungstenite::accept_async;
4
-use futures::{SinkExt, StreamExt};
5 4
 use log::*;
5
+use tokio::net::{TcpListener, TcpStream};
6
+use tokio::stream::StreamExt;
7
+use futures_tokio_compat::Compat;
8
+use futures::sink::SinkExt;
6 9
 
7 10
 fn config_dir() -> String {
8 11
     format!(
@@ -22,11 +25,8 @@ fn db_path() -> String {
22 25
     format!("{}/server.db", data_dir())
23 26
 }
24 27
 
25
-fn main() {
26
-    task::block_on(run());
27
-}
28
-
29
-async fn run() {
28
+#[tokio::main]
29
+async fn main() {
30 30
     env_logger::init();
31 31
 
32 32
     // Read configuration.
@@ -39,20 +39,25 @@ async fn run() {
39 39
 
40 40
     // Start the websocket server and listen for connections.
41 41
     let addr = "127.0.0.1:1199";
42
-    let listener = TcpListener::bind(&addr).await.unwrap();
42
+    let mut listener = TcpListener::bind(&addr)
43
+        .await
44
+        .expect("cannot bind to server port");
45
+    let mut incoming = listener.incoming();
43 46
     info!("Listening on {}.", addr);
44 47
 
45
-    while let Ok((stream, _)) = listener.accept().await {
48
+    while let Some(Ok(stream)) = incoming.next().await {
46 49
         let peer = stream
47 50
             .peer_addr()
48 51
             .expect("connected streams should have a peer address");
49 52
 
50
-        async_std::task::spawn(accept_connection(peer, stream));
53
+        tokio::spawn(accept_connection(peer, stream));
51 54
     }
52 55
 }
53 56
 
57
+// TODO: Robust error handling.
58
+
54 59
 async fn accept_connection(peer: SocketAddr, stream: TcpStream) {
55
-    let mut ws_stream = accept_async(stream).await.expect("Failed to accept");
60
+    let mut ws_stream = accept_async(Compat::new(stream)).await.expect("Failed to accept");
56 61
 
57 62
     info!("New WebSocket connection from {}.", peer);
58 63
 

Loading…
Annuler
Enregistrer