├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md └── src ├── domain ├── mod.rs └── news.rs ├── driver ├── mod.rs └── news_driver.rs ├── error.rs ├── gateway ├── mod.rs └── news_gateway.rs ├── main.rs ├── port ├── mod.rs └── news_port.rs ├── rest ├── mod.rs ├── news.rs └── systems.rs └── usecase ├── mod.rs └── news_get_usecase.rs /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .idea -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "actix" 5 | version = "0.9.0" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | checksum = "a4af87564ff659dee8f9981540cac9418c45e910c8072fdedd643a262a38fcaf" 8 | dependencies = [ 9 | "actix-http", 10 | "actix-rt", 11 | "actix_derive", 12 | "bitflags", 13 | "bytes", 14 | "crossbeam-channel", 15 | "derive_more", 16 | "futures", 17 | "lazy_static", 18 | "log", 19 | "parking_lot", 20 | "pin-project", 21 | "smallvec", 22 | "tokio", 23 | "tokio-util", 24 | "trust-dns-proto", 25 | "trust-dns-resolver", 26 | ] 27 | 28 | [[package]] 29 | name = "actix-codec" 30 | version = "0.2.0" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "09e55f0a5c2ca15795035d90c46bd0e73a5123b72f68f12596d6ba5282051380" 33 | dependencies = [ 34 | "bitflags", 35 | "bytes", 36 | "futures-core", 37 | "futures-sink", 38 | "log", 39 | "tokio", 40 | "tokio-util", 41 | ] 42 | 43 | [[package]] 44 | name = "actix-connect" 45 | version = "1.0.1" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "1f2b61480a8d30c94d5c883d79ef026b02ad6809931b0a4bb703f9545cd8c986" 48 | dependencies = [ 49 | "actix-codec", 50 | "actix-rt", 51 | "actix-service", 52 | "actix-utils", 53 | "derive_more", 54 | "either", 55 | "futures", 56 | "http", 57 | "log", 58 | "openssl", 59 | "tokio-openssl", 60 | "trust-dns-proto", 61 | "trust-dns-resolver", 62 | ] 63 | 64 | [[package]] 65 | name = "actix-http" 66 | version = "1.0.1" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "c16664cc4fdea8030837ad5a845eb231fb93fc3c5c171edfefb52fad92ce9019" 69 | dependencies = [ 70 | "actix-codec", 71 | "actix-connect", 72 | "actix-rt", 73 | "actix-service", 74 | "actix-threadpool", 75 | "actix-tls", 76 | "actix-utils", 77 | "base64", 78 | "bitflags", 79 | "brotli2", 80 | "bytes", 81 | "chrono", 82 | "copyless", 83 | "derive_more", 84 | "either", 85 | "encoding_rs", 86 | "failure", 87 | "flate2", 88 | "futures-channel", 89 | "futures-core", 90 | "futures-util", 91 | "fxhash", 92 | "h2", 93 | "http", 94 | "httparse", 95 | "indexmap", 96 | "language-tags", 97 | "lazy_static", 98 | "log", 99 | "mime", 100 | "percent-encoding", 101 | "pin-project", 102 | "rand", 103 | "regex", 104 | "serde", 105 | "serde_json", 106 | "serde_urlencoded", 107 | "sha1", 108 | "slab", 109 | "time", 110 | ] 111 | 112 | [[package]] 113 | name = "actix-macros" 114 | version = "0.1.1" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "21705adc76bbe4bc98434890e73a89cd00c6015e5704a60bb6eea6c3b72316b6" 117 | dependencies = [ 118 | "quote", 119 | "syn", 120 | ] 121 | 122 | [[package]] 123 | name = "actix-router" 124 | version = "0.2.4" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "9d7a10ca4d94e8c8e7a87c5173aba1b97ba9a6563ca02b0e1cd23531093d3ec8" 127 | dependencies = [ 128 | "bytestring", 129 | "http", 130 | "log", 131 | "regex", 132 | "serde", 133 | ] 134 | 135 | [[package]] 136 | name = "actix-rt" 137 | version = "1.0.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "3f6a0a55507046441a496b2f0d26a84a65e67c8cafffe279072412f624b5fb6d" 140 | dependencies = [ 141 | "actix-macros", 142 | "actix-threadpool", 143 | "copyless", 144 | "futures", 145 | "tokio", 146 | ] 147 | 148 | [[package]] 149 | name = "actix-server" 150 | version = "1.0.1" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "51d3455eaac03ca3e49d7b822eb35c884b861f715627254ccbe4309d08f1841a" 153 | dependencies = [ 154 | "actix-codec", 155 | "actix-rt", 156 | "actix-service", 157 | "actix-utils", 158 | "futures", 159 | "log", 160 | "mio", 161 | "mio-uds", 162 | "net2", 163 | "num_cpus", 164 | "slab", 165 | ] 166 | 167 | [[package]] 168 | name = "actix-service" 169 | version = "1.0.1" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "7a5ecef49693fcfe2c13a34c7218eb5b7898ff3fbe334db8445759f871fec2df" 172 | dependencies = [ 173 | "futures-util", 174 | "pin-project", 175 | ] 176 | 177 | [[package]] 178 | name = "actix-testing" 179 | version = "1.0.0" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "48494745b72d0ea8ff0cf874aaf9b622a3ee03d7081ee0c04edea4f26d32c911" 182 | dependencies = [ 183 | "actix-macros", 184 | "actix-rt", 185 | "actix-server", 186 | "actix-service", 187 | "futures", 188 | "log", 189 | "net2", 190 | ] 191 | 192 | [[package]] 193 | name = "actix-threadpool" 194 | version = "0.3.1" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "cf4082192601de5f303013709ff84d81ca6a1bc4af7fb24f367a500a23c6e84e" 197 | dependencies = [ 198 | "derive_more", 199 | "futures-channel", 200 | "lazy_static", 201 | "log", 202 | "num_cpus", 203 | "parking_lot", 204 | "threadpool", 205 | ] 206 | 207 | [[package]] 208 | name = "actix-tls" 209 | version = "1.0.0" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "a4e5b4faaf105e9a6d389c606c298dcdb033061b00d532af9df56ff3a54995a8" 212 | dependencies = [ 213 | "actix-codec", 214 | "actix-rt", 215 | "actix-service", 216 | "actix-utils", 217 | "derive_more", 218 | "either", 219 | "futures", 220 | "log", 221 | "openssl", 222 | "tokio-openssl", 223 | ] 224 | 225 | [[package]] 226 | name = "actix-utils" 227 | version = "1.0.4" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "a31d6e44d044cbad9d599eaac4007cf5194621c514b1324ea5116863357b04d5" 230 | dependencies = [ 231 | "actix-codec", 232 | "actix-rt", 233 | "actix-service", 234 | "bytes", 235 | "either", 236 | "futures", 237 | "log", 238 | "pin-project", 239 | ] 240 | 241 | [[package]] 242 | name = "actix-web" 243 | version = "2.0.0" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "3158e822461040822f0dbf1735b9c2ce1f95f93b651d7a7aded00b1efbb1f635" 246 | dependencies = [ 247 | "actix-codec", 248 | "actix-http", 249 | "actix-macros", 250 | "actix-router", 251 | "actix-rt", 252 | "actix-server", 253 | "actix-service", 254 | "actix-testing", 255 | "actix-threadpool", 256 | "actix-tls", 257 | "actix-utils", 258 | "actix-web-codegen", 259 | "awc", 260 | "bytes", 261 | "derive_more", 262 | "encoding_rs", 263 | "futures", 264 | "fxhash", 265 | "log", 266 | "mime", 267 | "net2", 268 | "openssl", 269 | "pin-project", 270 | "regex", 271 | "serde", 272 | "serde_json", 273 | "serde_urlencoded", 274 | "time", 275 | "url", 276 | ] 277 | 278 | [[package]] 279 | name = "actix-web-codegen" 280 | version = "0.2.0" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | checksum = "de0878b30e62623770a4713a6338329fd0119703bafc211d3e4144f4d4a7bdd5" 283 | dependencies = [ 284 | "proc-macro2", 285 | "quote", 286 | "syn", 287 | ] 288 | 289 | [[package]] 290 | name = "actix-web-sample" 291 | version = "0.1.0" 292 | dependencies = [ 293 | "actix", 294 | "actix-http", 295 | "actix-rt", 296 | "actix-web", 297 | "async-trait", 298 | "awc", 299 | "env_logger", 300 | "failure", 301 | "log", 302 | "serde", 303 | "serde_json", 304 | ] 305 | 306 | [[package]] 307 | name = "actix_derive" 308 | version = "0.5.0" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | checksum = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" 311 | dependencies = [ 312 | "proc-macro2", 313 | "quote", 314 | "syn", 315 | ] 316 | 317 | [[package]] 318 | name = "adler32" 319 | version = "1.0.4" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" 322 | 323 | [[package]] 324 | name = "aho-corasick" 325 | version = "0.7.6" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" 328 | dependencies = [ 329 | "memchr", 330 | ] 331 | 332 | [[package]] 333 | name = "arc-swap" 334 | version = "0.4.4" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" 337 | 338 | [[package]] 339 | name = "async-trait" 340 | version = "0.1.22" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "c8df72488e87761e772f14ae0c2480396810e51b2c2ade912f97f0f7e5b95e3c" 343 | dependencies = [ 344 | "proc-macro2", 345 | "quote", 346 | "syn", 347 | ] 348 | 349 | [[package]] 350 | name = "atty" 351 | version = "0.2.14" 352 | source = "registry+https://github.com/rust-lang/crates.io-index" 353 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 354 | dependencies = [ 355 | "hermit-abi", 356 | "libc", 357 | "winapi 0.3.8", 358 | ] 359 | 360 | [[package]] 361 | name = "autocfg" 362 | version = "0.1.7" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" 365 | 366 | [[package]] 367 | name = "awc" 368 | version = "1.0.1" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "d7601d4d1d7ef2335d6597a41b5fe069f6ab799b85f53565ab390e7b7065aac5" 371 | dependencies = [ 372 | "actix-codec", 373 | "actix-http", 374 | "actix-rt", 375 | "actix-service", 376 | "base64", 377 | "bytes", 378 | "derive_more", 379 | "futures-core", 380 | "log", 381 | "mime", 382 | "openssl", 383 | "percent-encoding", 384 | "rand", 385 | "serde", 386 | "serde_json", 387 | "serde_urlencoded", 388 | ] 389 | 390 | [[package]] 391 | name = "backtrace" 392 | version = "0.3.40" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" 395 | dependencies = [ 396 | "backtrace-sys", 397 | "cfg-if", 398 | "libc", 399 | "rustc-demangle", 400 | ] 401 | 402 | [[package]] 403 | name = "backtrace-sys" 404 | version = "0.1.32" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" 407 | dependencies = [ 408 | "cc", 409 | "libc", 410 | ] 411 | 412 | [[package]] 413 | name = "base64" 414 | version = "0.11.0" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" 417 | 418 | [[package]] 419 | name = "bitflags" 420 | version = "1.2.1" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 423 | 424 | [[package]] 425 | name = "brotli-sys" 426 | version = "0.3.2" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" 429 | dependencies = [ 430 | "cc", 431 | "libc", 432 | ] 433 | 434 | [[package]] 435 | name = "brotli2" 436 | version = "0.3.2" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" 439 | dependencies = [ 440 | "brotli-sys", 441 | "libc", 442 | ] 443 | 444 | [[package]] 445 | name = "byteorder" 446 | version = "1.3.2" 447 | source = "registry+https://github.com/rust-lang/crates.io-index" 448 | checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" 449 | 450 | [[package]] 451 | name = "bytes" 452 | version = "0.5.3" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "10004c15deb332055f7a4a208190aed362cf9a7c2f6ab70a305fba50e1105f38" 455 | 456 | [[package]] 457 | name = "bytestring" 458 | version = "0.1.2" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "b24c107a4432e408d2caa58d3f5e763b219236221406ea58a4076b62343a039d" 461 | dependencies = [ 462 | "bytes", 463 | ] 464 | 465 | [[package]] 466 | name = "c2-chacha" 467 | version = "0.2.3" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" 470 | dependencies = [ 471 | "ppv-lite86", 472 | ] 473 | 474 | [[package]] 475 | name = "cc" 476 | version = "1.0.49" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "e450b8da92aa6f274e7c6437692f9f2ce6d701fb73bacfcf87897b3f89a4c20e" 479 | 480 | [[package]] 481 | name = "cfg-if" 482 | version = "0.1.10" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 485 | 486 | [[package]] 487 | name = "chrono" 488 | version = "0.4.10" 489 | source = "registry+https://github.com/rust-lang/crates.io-index" 490 | checksum = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" 491 | dependencies = [ 492 | "num-integer", 493 | "num-traits", 494 | "time", 495 | ] 496 | 497 | [[package]] 498 | name = "cloudabi" 499 | version = "0.0.3" 500 | source = "registry+https://github.com/rust-lang/crates.io-index" 501 | checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 502 | dependencies = [ 503 | "bitflags", 504 | ] 505 | 506 | [[package]] 507 | name = "copyless" 508 | version = "0.1.4" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" 511 | 512 | [[package]] 513 | name = "crc32fast" 514 | version = "1.2.0" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" 517 | dependencies = [ 518 | "cfg-if", 519 | ] 520 | 521 | [[package]] 522 | name = "crossbeam-channel" 523 | version = "0.4.0" 524 | source = "registry+https://github.com/rust-lang/crates.io-index" 525 | checksum = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" 526 | dependencies = [ 527 | "crossbeam-utils", 528 | ] 529 | 530 | [[package]] 531 | name = "crossbeam-utils" 532 | version = "0.7.0" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" 535 | dependencies = [ 536 | "autocfg", 537 | "cfg-if", 538 | "lazy_static", 539 | ] 540 | 541 | [[package]] 542 | name = "derive_more" 543 | version = "0.99.2" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" 546 | dependencies = [ 547 | "proc-macro2", 548 | "quote", 549 | "syn", 550 | ] 551 | 552 | [[package]] 553 | name = "dtoa" 554 | version = "0.4.4" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" 557 | 558 | [[package]] 559 | name = "either" 560 | version = "1.5.3" 561 | source = "registry+https://github.com/rust-lang/crates.io-index" 562 | checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" 563 | 564 | [[package]] 565 | name = "encoding_rs" 566 | version = "0.8.22" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" 569 | dependencies = [ 570 | "cfg-if", 571 | ] 572 | 573 | [[package]] 574 | name = "enum-as-inner" 575 | version = "0.3.0" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "900a6c7fbe523f4c2884eaf26b57b81bb69b6810a01a236390a7ac021d09492e" 578 | dependencies = [ 579 | "heck", 580 | "proc-macro2", 581 | "quote", 582 | "syn", 583 | ] 584 | 585 | [[package]] 586 | name = "env_logger" 587 | version = "0.7.1" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" 590 | dependencies = [ 591 | "atty", 592 | "humantime", 593 | "log", 594 | "regex", 595 | "termcolor", 596 | ] 597 | 598 | [[package]] 599 | name = "failure" 600 | version = "0.1.6" 601 | source = "registry+https://github.com/rust-lang/crates.io-index" 602 | checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" 603 | dependencies = [ 604 | "backtrace", 605 | "failure_derive", 606 | ] 607 | 608 | [[package]] 609 | name = "failure_derive" 610 | version = "0.1.6" 611 | source = "registry+https://github.com/rust-lang/crates.io-index" 612 | checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" 613 | dependencies = [ 614 | "proc-macro2", 615 | "quote", 616 | "syn", 617 | "synstructure", 618 | ] 619 | 620 | [[package]] 621 | name = "flate2" 622 | version = "1.0.13" 623 | source = "registry+https://github.com/rust-lang/crates.io-index" 624 | checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" 625 | dependencies = [ 626 | "cfg-if", 627 | "crc32fast", 628 | "libc", 629 | "miniz_oxide", 630 | ] 631 | 632 | [[package]] 633 | name = "fnv" 634 | version = "1.0.6" 635 | source = "registry+https://github.com/rust-lang/crates.io-index" 636 | checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 637 | 638 | [[package]] 639 | name = "foreign-types" 640 | version = "0.3.2" 641 | source = "registry+https://github.com/rust-lang/crates.io-index" 642 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 643 | dependencies = [ 644 | "foreign-types-shared", 645 | ] 646 | 647 | [[package]] 648 | name = "foreign-types-shared" 649 | version = "0.1.1" 650 | source = "registry+https://github.com/rust-lang/crates.io-index" 651 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 652 | 653 | [[package]] 654 | name = "fuchsia-zircon" 655 | version = "0.3.3" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 658 | dependencies = [ 659 | "bitflags", 660 | "fuchsia-zircon-sys", 661 | ] 662 | 663 | [[package]] 664 | name = "fuchsia-zircon-sys" 665 | version = "0.3.3" 666 | source = "registry+https://github.com/rust-lang/crates.io-index" 667 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 668 | 669 | [[package]] 670 | name = "futures" 671 | version = "0.3.1" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" 674 | dependencies = [ 675 | "futures-channel", 676 | "futures-core", 677 | "futures-executor", 678 | "futures-io", 679 | "futures-sink", 680 | "futures-task", 681 | "futures-util", 682 | ] 683 | 684 | [[package]] 685 | name = "futures-channel" 686 | version = "0.3.1" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" 689 | dependencies = [ 690 | "futures-core", 691 | "futures-sink", 692 | ] 693 | 694 | [[package]] 695 | name = "futures-core" 696 | version = "0.3.1" 697 | source = "registry+https://github.com/rust-lang/crates.io-index" 698 | checksum = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" 699 | 700 | [[package]] 701 | name = "futures-executor" 702 | version = "0.3.1" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" 705 | dependencies = [ 706 | "futures-core", 707 | "futures-task", 708 | "futures-util", 709 | ] 710 | 711 | [[package]] 712 | name = "futures-io" 713 | version = "0.3.1" 714 | source = "registry+https://github.com/rust-lang/crates.io-index" 715 | checksum = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" 716 | 717 | [[package]] 718 | name = "futures-macro" 719 | version = "0.3.1" 720 | source = "registry+https://github.com/rust-lang/crates.io-index" 721 | checksum = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" 722 | dependencies = [ 723 | "proc-macro-hack", 724 | "proc-macro2", 725 | "quote", 726 | "syn", 727 | ] 728 | 729 | [[package]] 730 | name = "futures-sink" 731 | version = "0.3.1" 732 | source = "registry+https://github.com/rust-lang/crates.io-index" 733 | checksum = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" 734 | 735 | [[package]] 736 | name = "futures-task" 737 | version = "0.3.1" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" 740 | 741 | [[package]] 742 | name = "futures-util" 743 | version = "0.3.1" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" 746 | dependencies = [ 747 | "futures-channel", 748 | "futures-core", 749 | "futures-io", 750 | "futures-macro", 751 | "futures-sink", 752 | "futures-task", 753 | "memchr", 754 | "pin-utils", 755 | "proc-macro-hack", 756 | "proc-macro-nested", 757 | "slab", 758 | ] 759 | 760 | [[package]] 761 | name = "fxhash" 762 | version = "0.2.1" 763 | source = "registry+https://github.com/rust-lang/crates.io-index" 764 | checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" 765 | dependencies = [ 766 | "byteorder", 767 | ] 768 | 769 | [[package]] 770 | name = "getrandom" 771 | version = "0.1.13" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" 774 | dependencies = [ 775 | "cfg-if", 776 | "libc", 777 | "wasi", 778 | ] 779 | 780 | [[package]] 781 | name = "h2" 782 | version = "0.2.1" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" 785 | dependencies = [ 786 | "bytes", 787 | "fnv", 788 | "futures-core", 789 | "futures-sink", 790 | "futures-util", 791 | "http", 792 | "indexmap", 793 | "log", 794 | "slab", 795 | "tokio", 796 | "tokio-util", 797 | ] 798 | 799 | [[package]] 800 | name = "heck" 801 | version = "0.3.1" 802 | source = "registry+https://github.com/rust-lang/crates.io-index" 803 | checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" 804 | dependencies = [ 805 | "unicode-segmentation", 806 | ] 807 | 808 | [[package]] 809 | name = "hermit-abi" 810 | version = "0.1.6" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" 813 | dependencies = [ 814 | "libc", 815 | ] 816 | 817 | [[package]] 818 | name = "hostname" 819 | version = "0.1.5" 820 | source = "registry+https://github.com/rust-lang/crates.io-index" 821 | checksum = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e" 822 | dependencies = [ 823 | "libc", 824 | "winutil", 825 | ] 826 | 827 | [[package]] 828 | name = "http" 829 | version = "0.2.0" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" 832 | dependencies = [ 833 | "bytes", 834 | "fnv", 835 | "itoa", 836 | ] 837 | 838 | [[package]] 839 | name = "httparse" 840 | version = "1.3.4" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" 843 | 844 | [[package]] 845 | name = "humantime" 846 | version = "1.3.0" 847 | source = "registry+https://github.com/rust-lang/crates.io-index" 848 | checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 849 | dependencies = [ 850 | "quick-error", 851 | ] 852 | 853 | [[package]] 854 | name = "idna" 855 | version = "0.2.0" 856 | source = "registry+https://github.com/rust-lang/crates.io-index" 857 | checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" 858 | dependencies = [ 859 | "matches", 860 | "unicode-bidi", 861 | "unicode-normalization", 862 | ] 863 | 864 | [[package]] 865 | name = "indexmap" 866 | version = "1.3.0" 867 | source = "registry+https://github.com/rust-lang/crates.io-index" 868 | checksum = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" 869 | dependencies = [ 870 | "autocfg", 871 | ] 872 | 873 | [[package]] 874 | name = "iovec" 875 | version = "0.1.4" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 878 | dependencies = [ 879 | "libc", 880 | ] 881 | 882 | [[package]] 883 | name = "ipconfig" 884 | version = "0.2.1" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" 887 | dependencies = [ 888 | "socket2", 889 | "widestring", 890 | "winapi 0.3.8", 891 | "winreg", 892 | ] 893 | 894 | [[package]] 895 | name = "itoa" 896 | version = "0.4.4" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 899 | 900 | [[package]] 901 | name = "kernel32-sys" 902 | version = "0.2.2" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 905 | dependencies = [ 906 | "winapi 0.2.8", 907 | "winapi-build", 908 | ] 909 | 910 | [[package]] 911 | name = "language-tags" 912 | version = "0.2.2" 913 | source = "registry+https://github.com/rust-lang/crates.io-index" 914 | checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" 915 | 916 | [[package]] 917 | name = "lazy_static" 918 | version = "1.4.0" 919 | source = "registry+https://github.com/rust-lang/crates.io-index" 920 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 921 | 922 | [[package]] 923 | name = "libc" 924 | version = "0.2.66" 925 | source = "registry+https://github.com/rust-lang/crates.io-index" 926 | checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" 927 | 928 | [[package]] 929 | name = "linked-hash-map" 930 | version = "0.5.2" 931 | source = "registry+https://github.com/rust-lang/crates.io-index" 932 | checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" 933 | 934 | [[package]] 935 | name = "lock_api" 936 | version = "0.3.3" 937 | source = "registry+https://github.com/rust-lang/crates.io-index" 938 | checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" 939 | dependencies = [ 940 | "scopeguard", 941 | ] 942 | 943 | [[package]] 944 | name = "log" 945 | version = "0.4.8" 946 | source = "registry+https://github.com/rust-lang/crates.io-index" 947 | checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 948 | dependencies = [ 949 | "cfg-if", 950 | ] 951 | 952 | [[package]] 953 | name = "lru-cache" 954 | version = "0.1.2" 955 | source = "registry+https://github.com/rust-lang/crates.io-index" 956 | checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" 957 | dependencies = [ 958 | "linked-hash-map", 959 | ] 960 | 961 | [[package]] 962 | name = "matches" 963 | version = "0.1.8" 964 | source = "registry+https://github.com/rust-lang/crates.io-index" 965 | checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 966 | 967 | [[package]] 968 | name = "memchr" 969 | version = "2.2.1" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" 972 | 973 | [[package]] 974 | name = "mime" 975 | version = "0.3.15" 976 | source = "registry+https://github.com/rust-lang/crates.io-index" 977 | checksum = "61ab7b690f26f7b22cc1e6a5306da408904b75a0c833b9b0f7b3dfab3c8405d1" 978 | 979 | [[package]] 980 | name = "miniz_oxide" 981 | version = "0.3.5" 982 | source = "registry+https://github.com/rust-lang/crates.io-index" 983 | checksum = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" 984 | dependencies = [ 985 | "adler32", 986 | ] 987 | 988 | [[package]] 989 | name = "mio" 990 | version = "0.6.21" 991 | source = "registry+https://github.com/rust-lang/crates.io-index" 992 | checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" 993 | dependencies = [ 994 | "cfg-if", 995 | "fuchsia-zircon", 996 | "fuchsia-zircon-sys", 997 | "iovec", 998 | "kernel32-sys", 999 | "libc", 1000 | "log", 1001 | "miow", 1002 | "net2", 1003 | "slab", 1004 | "winapi 0.2.8", 1005 | ] 1006 | 1007 | [[package]] 1008 | name = "mio-uds" 1009 | version = "0.6.7" 1010 | source = "registry+https://github.com/rust-lang/crates.io-index" 1011 | checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" 1012 | dependencies = [ 1013 | "iovec", 1014 | "libc", 1015 | "mio", 1016 | ] 1017 | 1018 | [[package]] 1019 | name = "miow" 1020 | version = "0.2.1" 1021 | source = "registry+https://github.com/rust-lang/crates.io-index" 1022 | checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" 1023 | dependencies = [ 1024 | "kernel32-sys", 1025 | "net2", 1026 | "winapi 0.2.8", 1027 | "ws2_32-sys", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "net2" 1032 | version = "0.2.33" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" 1035 | dependencies = [ 1036 | "cfg-if", 1037 | "libc", 1038 | "winapi 0.3.8", 1039 | ] 1040 | 1041 | [[package]] 1042 | name = "num-integer" 1043 | version = "0.1.41" 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" 1045 | checksum = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" 1046 | dependencies = [ 1047 | "autocfg", 1048 | "num-traits", 1049 | ] 1050 | 1051 | [[package]] 1052 | name = "num-traits" 1053 | version = "0.2.10" 1054 | source = "registry+https://github.com/rust-lang/crates.io-index" 1055 | checksum = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" 1056 | dependencies = [ 1057 | "autocfg", 1058 | ] 1059 | 1060 | [[package]] 1061 | name = "num_cpus" 1062 | version = "1.11.1" 1063 | source = "registry+https://github.com/rust-lang/crates.io-index" 1064 | checksum = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" 1065 | dependencies = [ 1066 | "hermit-abi", 1067 | "libc", 1068 | ] 1069 | 1070 | [[package]] 1071 | name = "openssl" 1072 | version = "0.10.26" 1073 | source = "registry+https://github.com/rust-lang/crates.io-index" 1074 | checksum = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" 1075 | dependencies = [ 1076 | "bitflags", 1077 | "cfg-if", 1078 | "foreign-types", 1079 | "lazy_static", 1080 | "libc", 1081 | "openssl-sys", 1082 | ] 1083 | 1084 | [[package]] 1085 | name = "openssl-sys" 1086 | version = "0.9.53" 1087 | source = "registry+https://github.com/rust-lang/crates.io-index" 1088 | checksum = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" 1089 | dependencies = [ 1090 | "autocfg", 1091 | "cc", 1092 | "libc", 1093 | "pkg-config", 1094 | "vcpkg", 1095 | ] 1096 | 1097 | [[package]] 1098 | name = "parking_lot" 1099 | version = "0.10.0" 1100 | source = "registry+https://github.com/rust-lang/crates.io-index" 1101 | checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" 1102 | dependencies = [ 1103 | "lock_api", 1104 | "parking_lot_core", 1105 | ] 1106 | 1107 | [[package]] 1108 | name = "parking_lot_core" 1109 | version = "0.7.0" 1110 | source = "registry+https://github.com/rust-lang/crates.io-index" 1111 | checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" 1112 | dependencies = [ 1113 | "cfg-if", 1114 | "cloudabi", 1115 | "libc", 1116 | "redox_syscall", 1117 | "smallvec", 1118 | "winapi 0.3.8", 1119 | ] 1120 | 1121 | [[package]] 1122 | name = "percent-encoding" 1123 | version = "2.1.0" 1124 | source = "registry+https://github.com/rust-lang/crates.io-index" 1125 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 1126 | 1127 | [[package]] 1128 | name = "pin-project" 1129 | version = "0.4.6" 1130 | source = "registry+https://github.com/rust-lang/crates.io-index" 1131 | checksum = "94b90146c7216e4cb534069fb91366de4ea0ea353105ee45ed297e2d1619e469" 1132 | dependencies = [ 1133 | "pin-project-internal", 1134 | ] 1135 | 1136 | [[package]] 1137 | name = "pin-project-internal" 1138 | version = "0.4.6" 1139 | source = "registry+https://github.com/rust-lang/crates.io-index" 1140 | checksum = "44ca92f893f0656d3cba8158dd0f2b99b94de256a4a54e870bd6922fcc6c8355" 1141 | dependencies = [ 1142 | "proc-macro2", 1143 | "quote", 1144 | "syn", 1145 | ] 1146 | 1147 | [[package]] 1148 | name = "pin-project-lite" 1149 | version = "0.1.2" 1150 | source = "registry+https://github.com/rust-lang/crates.io-index" 1151 | checksum = "e8822eb8bb72452f038ebf6048efa02c3fe22bf83f76519c9583e47fc194a422" 1152 | 1153 | [[package]] 1154 | name = "pin-utils" 1155 | version = "0.1.0-alpha.4" 1156 | source = "registry+https://github.com/rust-lang/crates.io-index" 1157 | checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" 1158 | 1159 | [[package]] 1160 | name = "pkg-config" 1161 | version = "0.3.17" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" 1164 | 1165 | [[package]] 1166 | name = "ppv-lite86" 1167 | version = "0.2.6" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" 1170 | 1171 | [[package]] 1172 | name = "proc-macro-hack" 1173 | version = "0.5.11" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" 1176 | dependencies = [ 1177 | "proc-macro2", 1178 | "quote", 1179 | "syn", 1180 | ] 1181 | 1182 | [[package]] 1183 | name = "proc-macro-nested" 1184 | version = "0.1.3" 1185 | source = "registry+https://github.com/rust-lang/crates.io-index" 1186 | checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" 1187 | 1188 | [[package]] 1189 | name = "proc-macro2" 1190 | version = "1.0.7" 1191 | source = "registry+https://github.com/rust-lang/crates.io-index" 1192 | checksum = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" 1193 | dependencies = [ 1194 | "unicode-xid", 1195 | ] 1196 | 1197 | [[package]] 1198 | name = "quick-error" 1199 | version = "1.2.3" 1200 | source = "registry+https://github.com/rust-lang/crates.io-index" 1201 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 1202 | 1203 | [[package]] 1204 | name = "quote" 1205 | version = "1.0.2" 1206 | source = "registry+https://github.com/rust-lang/crates.io-index" 1207 | checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 1208 | dependencies = [ 1209 | "proc-macro2", 1210 | ] 1211 | 1212 | [[package]] 1213 | name = "rand" 1214 | version = "0.7.2" 1215 | source = "registry+https://github.com/rust-lang/crates.io-index" 1216 | checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" 1217 | dependencies = [ 1218 | "getrandom", 1219 | "libc", 1220 | "rand_chacha", 1221 | "rand_core", 1222 | "rand_hc", 1223 | ] 1224 | 1225 | [[package]] 1226 | name = "rand_chacha" 1227 | version = "0.2.1" 1228 | source = "registry+https://github.com/rust-lang/crates.io-index" 1229 | checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" 1230 | dependencies = [ 1231 | "c2-chacha", 1232 | "rand_core", 1233 | ] 1234 | 1235 | [[package]] 1236 | name = "rand_core" 1237 | version = "0.5.1" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 1240 | dependencies = [ 1241 | "getrandom", 1242 | ] 1243 | 1244 | [[package]] 1245 | name = "rand_hc" 1246 | version = "0.2.0" 1247 | source = "registry+https://github.com/rust-lang/crates.io-index" 1248 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 1249 | dependencies = [ 1250 | "rand_core", 1251 | ] 1252 | 1253 | [[package]] 1254 | name = "redox_syscall" 1255 | version = "0.1.56" 1256 | source = "registry+https://github.com/rust-lang/crates.io-index" 1257 | checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" 1258 | 1259 | [[package]] 1260 | name = "regex" 1261 | version = "1.3.1" 1262 | source = "registry+https://github.com/rust-lang/crates.io-index" 1263 | checksum = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" 1264 | dependencies = [ 1265 | "aho-corasick", 1266 | "memchr", 1267 | "regex-syntax", 1268 | "thread_local", 1269 | ] 1270 | 1271 | [[package]] 1272 | name = "regex-syntax" 1273 | version = "0.6.12" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" 1276 | 1277 | [[package]] 1278 | name = "resolv-conf" 1279 | version = "0.6.2" 1280 | source = "registry+https://github.com/rust-lang/crates.io-index" 1281 | checksum = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb" 1282 | dependencies = [ 1283 | "hostname", 1284 | "quick-error", 1285 | ] 1286 | 1287 | [[package]] 1288 | name = "rustc-demangle" 1289 | version = "0.1.16" 1290 | source = "registry+https://github.com/rust-lang/crates.io-index" 1291 | checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" 1292 | 1293 | [[package]] 1294 | name = "ryu" 1295 | version = "1.0.2" 1296 | source = "registry+https://github.com/rust-lang/crates.io-index" 1297 | checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" 1298 | 1299 | [[package]] 1300 | name = "scopeguard" 1301 | version = "1.0.0" 1302 | source = "registry+https://github.com/rust-lang/crates.io-index" 1303 | checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" 1304 | 1305 | [[package]] 1306 | name = "serde" 1307 | version = "1.0.104" 1308 | source = "registry+https://github.com/rust-lang/crates.io-index" 1309 | checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" 1310 | dependencies = [ 1311 | "serde_derive", 1312 | ] 1313 | 1314 | [[package]] 1315 | name = "serde_derive" 1316 | version = "1.0.104" 1317 | source = "registry+https://github.com/rust-lang/crates.io-index" 1318 | checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" 1319 | dependencies = [ 1320 | "proc-macro2", 1321 | "quote", 1322 | "syn", 1323 | ] 1324 | 1325 | [[package]] 1326 | name = "serde_json" 1327 | version = "1.0.44" 1328 | source = "registry+https://github.com/rust-lang/crates.io-index" 1329 | checksum = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" 1330 | dependencies = [ 1331 | "itoa", 1332 | "ryu", 1333 | "serde", 1334 | ] 1335 | 1336 | [[package]] 1337 | name = "serde_urlencoded" 1338 | version = "0.6.1" 1339 | source = "registry+https://github.com/rust-lang/crates.io-index" 1340 | checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" 1341 | dependencies = [ 1342 | "dtoa", 1343 | "itoa", 1344 | "serde", 1345 | "url", 1346 | ] 1347 | 1348 | [[package]] 1349 | name = "sha1" 1350 | version = "0.6.0" 1351 | source = "registry+https://github.com/rust-lang/crates.io-index" 1352 | checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" 1353 | 1354 | [[package]] 1355 | name = "signal-hook-registry" 1356 | version = "1.2.0" 1357 | source = "registry+https://github.com/rust-lang/crates.io-index" 1358 | checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" 1359 | dependencies = [ 1360 | "arc-swap", 1361 | "libc", 1362 | ] 1363 | 1364 | [[package]] 1365 | name = "slab" 1366 | version = "0.4.2" 1367 | source = "registry+https://github.com/rust-lang/crates.io-index" 1368 | checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" 1369 | 1370 | [[package]] 1371 | name = "smallvec" 1372 | version = "1.1.0" 1373 | source = "registry+https://github.com/rust-lang/crates.io-index" 1374 | checksum = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" 1375 | 1376 | [[package]] 1377 | name = "socket2" 1378 | version = "0.3.11" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" 1381 | dependencies = [ 1382 | "cfg-if", 1383 | "libc", 1384 | "redox_syscall", 1385 | "winapi 0.3.8", 1386 | ] 1387 | 1388 | [[package]] 1389 | name = "syn" 1390 | version = "1.0.13" 1391 | source = "registry+https://github.com/rust-lang/crates.io-index" 1392 | checksum = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" 1393 | dependencies = [ 1394 | "proc-macro2", 1395 | "quote", 1396 | "unicode-xid", 1397 | ] 1398 | 1399 | [[package]] 1400 | name = "synstructure" 1401 | version = "0.12.3" 1402 | source = "registry+https://github.com/rust-lang/crates.io-index" 1403 | checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" 1404 | dependencies = [ 1405 | "proc-macro2", 1406 | "quote", 1407 | "syn", 1408 | "unicode-xid", 1409 | ] 1410 | 1411 | [[package]] 1412 | name = "termcolor" 1413 | version = "1.0.5" 1414 | source = "registry+https://github.com/rust-lang/crates.io-index" 1415 | checksum = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" 1416 | dependencies = [ 1417 | "wincolor", 1418 | ] 1419 | 1420 | [[package]] 1421 | name = "thread_local" 1422 | version = "0.3.6" 1423 | source = "registry+https://github.com/rust-lang/crates.io-index" 1424 | checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" 1425 | dependencies = [ 1426 | "lazy_static", 1427 | ] 1428 | 1429 | [[package]] 1430 | name = "threadpool" 1431 | version = "1.7.1" 1432 | source = "registry+https://github.com/rust-lang/crates.io-index" 1433 | checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" 1434 | dependencies = [ 1435 | "num_cpus", 1436 | ] 1437 | 1438 | [[package]] 1439 | name = "time" 1440 | version = "0.1.42" 1441 | source = "registry+https://github.com/rust-lang/crates.io-index" 1442 | checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" 1443 | dependencies = [ 1444 | "libc", 1445 | "redox_syscall", 1446 | "winapi 0.3.8", 1447 | ] 1448 | 1449 | [[package]] 1450 | name = "tokio" 1451 | version = "0.2.6" 1452 | source = "registry+https://github.com/rust-lang/crates.io-index" 1453 | checksum = "0e1bef565a52394086ecac0a6fa3b8ace4cb3a138ee1d96bd2b93283b56824e3" 1454 | dependencies = [ 1455 | "bytes", 1456 | "fnv", 1457 | "futures-core", 1458 | "iovec", 1459 | "lazy_static", 1460 | "libc", 1461 | "memchr", 1462 | "mio", 1463 | "mio-uds", 1464 | "pin-project-lite", 1465 | "signal-hook-registry", 1466 | "slab", 1467 | "winapi 0.3.8", 1468 | ] 1469 | 1470 | [[package]] 1471 | name = "tokio-openssl" 1472 | version = "0.4.0" 1473 | source = "registry+https://github.com/rust-lang/crates.io-index" 1474 | checksum = "3c4b08c5f4208e699ede3df2520aca2e82401b2de33f45e96696a074480be594" 1475 | dependencies = [ 1476 | "openssl", 1477 | "tokio", 1478 | ] 1479 | 1480 | [[package]] 1481 | name = "tokio-util" 1482 | version = "0.2.0" 1483 | source = "registry+https://github.com/rust-lang/crates.io-index" 1484 | checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" 1485 | dependencies = [ 1486 | "bytes", 1487 | "futures-core", 1488 | "futures-sink", 1489 | "log", 1490 | "pin-project-lite", 1491 | "tokio", 1492 | ] 1493 | 1494 | [[package]] 1495 | name = "trust-dns-proto" 1496 | version = "0.18.0-alpha.2" 1497 | source = "registry+https://github.com/rust-lang/crates.io-index" 1498 | checksum = "2a7f3a2ab8a919f5eca52a468866a67ed7d3efa265d48a652a9a3452272b413f" 1499 | dependencies = [ 1500 | "async-trait", 1501 | "enum-as-inner", 1502 | "failure", 1503 | "futures", 1504 | "idna", 1505 | "lazy_static", 1506 | "log", 1507 | "rand", 1508 | "smallvec", 1509 | "socket2", 1510 | "tokio", 1511 | "url", 1512 | ] 1513 | 1514 | [[package]] 1515 | name = "trust-dns-resolver" 1516 | version = "0.18.0-alpha.2" 1517 | source = "registry+https://github.com/rust-lang/crates.io-index" 1518 | checksum = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f" 1519 | dependencies = [ 1520 | "cfg-if", 1521 | "failure", 1522 | "futures", 1523 | "ipconfig", 1524 | "lazy_static", 1525 | "log", 1526 | "lru-cache", 1527 | "resolv-conf", 1528 | "smallvec", 1529 | "tokio", 1530 | "trust-dns-proto", 1531 | ] 1532 | 1533 | [[package]] 1534 | name = "unicode-bidi" 1535 | version = "0.3.4" 1536 | source = "registry+https://github.com/rust-lang/crates.io-index" 1537 | checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" 1538 | dependencies = [ 1539 | "matches", 1540 | ] 1541 | 1542 | [[package]] 1543 | name = "unicode-normalization" 1544 | version = "0.1.11" 1545 | source = "registry+https://github.com/rust-lang/crates.io-index" 1546 | checksum = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" 1547 | dependencies = [ 1548 | "smallvec", 1549 | ] 1550 | 1551 | [[package]] 1552 | name = "unicode-segmentation" 1553 | version = "1.6.0" 1554 | source = "registry+https://github.com/rust-lang/crates.io-index" 1555 | checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" 1556 | 1557 | [[package]] 1558 | name = "unicode-xid" 1559 | version = "0.2.0" 1560 | source = "registry+https://github.com/rust-lang/crates.io-index" 1561 | checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 1562 | 1563 | [[package]] 1564 | name = "url" 1565 | version = "2.1.0" 1566 | source = "registry+https://github.com/rust-lang/crates.io-index" 1567 | checksum = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" 1568 | dependencies = [ 1569 | "idna", 1570 | "matches", 1571 | "percent-encoding", 1572 | ] 1573 | 1574 | [[package]] 1575 | name = "vcpkg" 1576 | version = "0.2.8" 1577 | source = "registry+https://github.com/rust-lang/crates.io-index" 1578 | checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" 1579 | 1580 | [[package]] 1581 | name = "wasi" 1582 | version = "0.7.0" 1583 | source = "registry+https://github.com/rust-lang/crates.io-index" 1584 | checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" 1585 | 1586 | [[package]] 1587 | name = "widestring" 1588 | version = "0.4.0" 1589 | source = "registry+https://github.com/rust-lang/crates.io-index" 1590 | checksum = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" 1591 | 1592 | [[package]] 1593 | name = "winapi" 1594 | version = "0.2.8" 1595 | source = "registry+https://github.com/rust-lang/crates.io-index" 1596 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 1597 | 1598 | [[package]] 1599 | name = "winapi" 1600 | version = "0.3.8" 1601 | source = "registry+https://github.com/rust-lang/crates.io-index" 1602 | checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" 1603 | dependencies = [ 1604 | "winapi-i686-pc-windows-gnu", 1605 | "winapi-x86_64-pc-windows-gnu", 1606 | ] 1607 | 1608 | [[package]] 1609 | name = "winapi-build" 1610 | version = "0.1.1" 1611 | source = "registry+https://github.com/rust-lang/crates.io-index" 1612 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 1613 | 1614 | [[package]] 1615 | name = "winapi-i686-pc-windows-gnu" 1616 | version = "0.4.0" 1617 | source = "registry+https://github.com/rust-lang/crates.io-index" 1618 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1619 | 1620 | [[package]] 1621 | name = "winapi-util" 1622 | version = "0.1.2" 1623 | source = "registry+https://github.com/rust-lang/crates.io-index" 1624 | checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" 1625 | dependencies = [ 1626 | "winapi 0.3.8", 1627 | ] 1628 | 1629 | [[package]] 1630 | name = "winapi-x86_64-pc-windows-gnu" 1631 | version = "0.4.0" 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" 1633 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1634 | 1635 | [[package]] 1636 | name = "wincolor" 1637 | version = "1.0.2" 1638 | source = "registry+https://github.com/rust-lang/crates.io-index" 1639 | checksum = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9" 1640 | dependencies = [ 1641 | "winapi 0.3.8", 1642 | "winapi-util", 1643 | ] 1644 | 1645 | [[package]] 1646 | name = "winreg" 1647 | version = "0.6.2" 1648 | source = "registry+https://github.com/rust-lang/crates.io-index" 1649 | checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" 1650 | dependencies = [ 1651 | "winapi 0.3.8", 1652 | ] 1653 | 1654 | [[package]] 1655 | name = "winutil" 1656 | version = "0.1.1" 1657 | source = "registry+https://github.com/rust-lang/crates.io-index" 1658 | checksum = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" 1659 | dependencies = [ 1660 | "winapi 0.3.8", 1661 | ] 1662 | 1663 | [[package]] 1664 | name = "ws2_32-sys" 1665 | version = "0.2.1" 1666 | source = "registry+https://github.com/rust-lang/crates.io-index" 1667 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 1668 | dependencies = [ 1669 | "winapi 0.2.8", 1670 | "winapi-build", 1671 | ] 1672 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "actix-web-sample" 3 | version = "0.1.0" 4 | authors = ["Takanori Ishibashi"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | actix = "0.9" 11 | actix-web = { version = "2.0.0", features = ["openssl"] } 12 | actix-rt = "1.0" 13 | actix-http = "1.0.1" 14 | log = "0.4.0" 15 | env_logger = "0.7.1" 16 | failure = "0.1.6" 17 | serde = "1.0.104" 18 | serde_json = "1.0" 19 | async-trait = "0.1.22" 20 | awc = "1.0.1" 21 | 22 | [profile.release] 23 | opt-level = 'z' 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # actix-web-clean-architecture-sample 2 | -------------------------------------------------------------------------------- /src/domain/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod news; 2 | -------------------------------------------------------------------------------- /src/domain/news.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Clone, Copy)] 2 | pub struct NewsId(pub u32); 3 | 4 | pub type NewsIds = Vec; 5 | 6 | #[derive(Debug, Clone)] 7 | pub struct News { 8 | pub id: NewsId, 9 | pub parent_id: NewsId, 10 | pub text: String, 11 | } 12 | 13 | pub type NewsList = Vec; 14 | 15 | impl News { 16 | pub fn new(id: NewsId, parent_id: NewsId, text: impl Into) -> Self { 17 | News { 18 | id, 19 | parent_id, 20 | text: text.into(), 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/driver/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod news_driver; 2 | -------------------------------------------------------------------------------- /src/driver/news_driver.rs: -------------------------------------------------------------------------------- 1 | use crate::error::Error; 2 | use actix_web::client::Client; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | pub async fn get_news(id: u32) -> Result { 6 | let json = Client::default() 7 | .get(format!("https://news.example.com/v0/item/{}/.json", id)) 8 | .send() 9 | .await? 10 | .json::() 11 | .await?; 12 | Ok(json) 13 | } 14 | 15 | pub async fn get_news_ids() -> Result { 16 | let json = Client::default() 17 | .get("https://news.example.com/v0/topstories.json") 18 | .send() 19 | .await? 20 | .json::() 21 | .await?; 22 | Ok(json) 23 | } 24 | 25 | #[derive(Serialize, Deserialize, Debug)] 26 | pub struct NewsJson { 27 | by: String, 28 | pub id: u32, 29 | pub parent: Option, 30 | pub text: Option, 31 | time: u32, 32 | } 33 | 34 | type NewsIdsJson = Vec; 35 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | use actix_web::{http::StatusCode, HttpResponse}; 2 | use failure::Fail; 3 | 4 | // FIXME: error handling 5 | 6 | #[derive(Fail, Debug)] 7 | pub enum Error { 8 | #[fail(display = "An internal error occurred. Please try again later.")] 9 | InternalServerError, 10 | #[fail(display = "Not Found")] 11 | NotFound, 12 | } 13 | 14 | impl actix_web::error::ResponseError for Error { 15 | fn status_code(&self) -> StatusCode { 16 | match *self { 17 | Error::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR, 18 | Error::NotFound => StatusCode::NOT_FOUND, 19 | } 20 | } 21 | 22 | fn error_response(&self) -> HttpResponse { 23 | match *self { 24 | Error::NotFound => HttpResponse::NotFound().json("Not Found"), 25 | Error::InternalServerError => { 26 | HttpResponse::InternalServerError().json("Internal Server Error") 27 | } 28 | } 29 | } 30 | } 31 | 32 | impl From for Error { 33 | fn from(_error: awc::error::SendRequestError) -> Self { 34 | Error::InternalServerError 35 | } 36 | } 37 | 38 | impl From for Error { 39 | fn from(_error: awc::error::JsonPayloadError) -> Self { 40 | Error::InternalServerError 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/gateway/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod news_gateway; 2 | -------------------------------------------------------------------------------- /src/gateway/news_gateway.rs: -------------------------------------------------------------------------------- 1 | use crate::domain::news::{News, NewsId, NewsIds, NewsList}; 2 | use crate::driver::news_driver; 3 | use crate::error::Error; 4 | use crate::port::news_port::NewsPort; 5 | use async_trait::async_trait; 6 | 7 | #[derive(Debug, Copy, Clone)] 8 | pub struct NewsGateway; 9 | 10 | #[async_trait(?Send)] 11 | impl NewsPort for NewsGateway { 12 | async fn find_news(&self, ids: NewsIds) -> Result { 13 | let mut json = vec![]; 14 | 15 | // TODO: call news_driver::get_news asynchronously 16 | for id in ids { 17 | let news_json = news_driver::get_news(id.0).await; 18 | json.push(news_json) 19 | } 20 | 21 | Ok(json 22 | .into_iter() 23 | .filter_map(Result::ok) 24 | .map(|n| { 25 | News::new( 26 | NewsId(n.id), 27 | NewsId(n.parent.unwrap_or(0)), 28 | n.text.unwrap_or("".to_string()), 29 | ) 30 | }) 31 | .collect::()) 32 | } 33 | 34 | async fn find_news_ids(&self) -> Result { 35 | let news_id_json = news_driver::get_news_ids().await; 36 | match news_id_json { 37 | Ok(ids) => Ok(ids 38 | .into_iter() 39 | .map(|id| NewsId(id)) 40 | .collect::>()), 41 | Err(e) => Err(e), 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod domain; 2 | mod driver; 3 | mod error; 4 | mod gateway; 5 | mod port; 6 | mod rest; 7 | mod usecase; 8 | 9 | #[macro_use] 10 | extern crate log; 11 | 12 | use std::env; 13 | 14 | fn main() { 15 | std::env::set_var("RUST_BACKTRACE", "1"); 16 | 17 | if env::var("RUST_LOG").ok().is_none() { 18 | env::set_var("RUST_LOG", "info"); 19 | } 20 | 21 | env_logger::init(); 22 | 23 | let sys = actix::System::new("actix-web-sample"); 24 | if let Err(e) = rest::build() { 25 | error!("ERROR: {:?}!", e); 26 | } 27 | 28 | let _ = sys.run(); 29 | } 30 | -------------------------------------------------------------------------------- /src/port/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod news_port; 2 | -------------------------------------------------------------------------------- /src/port/news_port.rs: -------------------------------------------------------------------------------- 1 | use crate::domain::news::{NewsIds, NewsList}; 2 | use crate::error::Error; 3 | use async_trait::async_trait; 4 | 5 | #[async_trait(?Send)] 6 | pub trait NewsPort { 7 | async fn find_news(&self, ids: NewsIds) -> Result; 8 | async fn find_news_ids(&self) -> Result; 9 | } 10 | -------------------------------------------------------------------------------- /src/rest/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::gateway::news_gateway::NewsGateway; 2 | use actix_web::middleware::Logger; 3 | use actix_web::{web, App, HttpServer}; 4 | 5 | pub mod news; 6 | pub mod systems; 7 | 8 | #[actix_rt::main] 9 | pub async fn build() -> std::io::Result<()> { 10 | HttpServer::new(|| { 11 | App::new() 12 | .data(Container { 13 | news_port: NewsGateway {}, 14 | }) 15 | .wrap(Logger::default()) 16 | .configure(routes) 17 | }) 18 | .bind("0.0.0.0:3333")? 19 | .run() 20 | .await 21 | } 22 | 23 | fn routes(app: &mut web::ServiceConfig) { 24 | app.service(web::resource("/healthz").route(web::get().to(systems::healthz))) 25 | .service(web::resource("v1/news").route(web::get().to(news::news))); 26 | } 27 | 28 | pub struct Container { 29 | news_port: NewsGateway, 30 | } 31 | -------------------------------------------------------------------------------- /src/rest/news.rs: -------------------------------------------------------------------------------- 1 | use crate::domain::news::News; 2 | use crate::rest::Container; 3 | use crate::usecase::news_get_usecase; 4 | use actix_web::{web, HttpResponse, Responder}; 5 | use serde::{Deserialize, Serialize}; 6 | 7 | pub async fn news(data: web::Data) -> impl Responder { 8 | let news = news_get_usecase::execute(data.news_port).await; 9 | 10 | match news { 11 | Ok(news) => HttpResponse::Ok().json( 12 | news.into_iter() 13 | .map(|news| NewsJson::from(news)) 14 | .collect::>(), 15 | ), 16 | // FIXME: error handling 17 | Err(_) => HttpResponse::InternalServerError().json(""), 18 | } 19 | } 20 | 21 | #[derive(Serialize, Deserialize, Debug)] 22 | struct NewsJson { 23 | id: u32, 24 | parent_id: u32, 25 | text: String, 26 | } 27 | 28 | impl NewsJson { 29 | fn from(news: News) -> Self { 30 | NewsJson { 31 | id: news.id.0, 32 | parent_id: news.parent_id.0, 33 | text: news.text, 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/rest/systems.rs: -------------------------------------------------------------------------------- 1 | use actix_web::{HttpResponse, Responder}; 2 | use serde_json::json; 3 | 4 | pub async fn healthz() -> impl Responder { 5 | HttpResponse::Ok().json(json!({ 6 | "status": "ok" 7 | })) 8 | } 9 | -------------------------------------------------------------------------------- /src/usecase/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod news_get_usecase; 2 | -------------------------------------------------------------------------------- /src/usecase/news_get_usecase.rs: -------------------------------------------------------------------------------- 1 | use crate::domain::news::NewsList; 2 | use crate::error::Error; 3 | use crate::port::news_port::NewsPort; 4 | 5 | pub async fn execute(news_port: impl NewsPort) -> Result { 6 | let news_ids = news_port.find_news_ids().await?; 7 | news_port 8 | .find_news(news_ids.into_iter().take(5).collect()) 9 | .await 10 | } 11 | --------------------------------------------------------------------------------