From f0e16bbfe769989d85b94cd8732a60f84f677e04 Mon Sep 17 00:00:00 2001 From: Daniel Joyce Date: Thu, 1 Apr 2021 20:58:48 -0700 Subject: [PATCH 01/13] Okay another rewrite. * Update dependencies * Tweak readme * Fix rustfmt file * Format files --- Cargo.lock | 1488 ++++++++++++++++++++++++++-------- Cargo.toml | 30 +- README.md | 4 +- rustfmt.toml | 12 +- src/lib/cfg.rs | 5 +- src/lib/dynamic_sleep.rs | 2 +- src/lib/manager.rs | 4 +- src/lib/port_manager.rs | 32 +- src/lib/sub_manager.rs | 1 - src/lib/writelock_manager.rs | 1 - 10 files changed, 1207 insertions(+), 372 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a04290..445b8d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,830 +1,1672 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "CoreFoundation-sys" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0e9889e6db118d49d88d84728d0e964d973a5680befb5f85f55141beea5c20b" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "mach 0.1.2", ] [[package]] name = "IOKit-sys" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99696c398cbaf669d2368076bdb3d627fb0ce51a26899d7c61228c5c0af3bf4a" dependencies = [ - "CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "CoreFoundation-sys", + "libc", + "mach 0.1.2", ] +[[package]] +name = "addr2line" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" -version = "0.6.9" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "argparse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] [[package]] name = "autocfg" -version = "0.1.1" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "autocfg" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.13" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ - "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", ] [[package]] -name = "backtrace-sys" -version = "0.1.28" +name = "base64" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "safemem", ] [[package]] name = "base64" -version = "0.5.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", ] [[package]] name = "base64" -version = "0.9.3" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block-buffer" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding", + "byte-tools", + "byteorder", + "generic-array", ] [[package]] -name = "bitflags" -version = "0.8.2" +name = "block-padding" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] [[package]] -name = "bitflags" -version = "0.9.1" +name = "boxfnonce" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5988cb1d626264ac94100be357308f29ff7cbdd3b36bda27f450a4ee3f713426" [[package]] -name = "bitflags" -version = "1.0.4" +name = "byte-tools" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "iovec", ] +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + [[package]] name = "cc" -version = "1.0.28" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" + +[[package]] +name = "cfg-if" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" -version = "0.1.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.0.1", + "cfg-if 0.1.10", + "lazy_static", +] [[package]] name = "daemonize" -version = "0.2.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70c24513e34f53b640819f0ac9f705b673fcf4006d7aab8778bee72ebfc89815" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "boxfnonce", + "libc", ] [[package]] name = "debug_stub_derive" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496b7f8a2f853313c3ca370641d7ff3e42c32974fdccda8f0684599ed0a3ff6b" +dependencies = [ + "quote 0.3.15", + "syn 0.11.11", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array", ] [[package]] name = "env_logger" -version = "0.4.3" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "humantime", + "log 0.4.14", + "regex", + "termcolor", ] [[package]] name = "error-chain" -version = "0.10.0" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ - "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace", + "version_check 0.9.3", ] +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foreign-types" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types-shared", ] [[package]] name = "foreign-types-shared" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "fuchsia-zircon-sys", ] [[package]] name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "futures-channel" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" + +[[package]] +name = "futures-task" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" + +[[package]] +name = "futures-util" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" +dependencies = [ + "bytes 1.0.1", + "fnv", + "itoa", +] [[package]] -name = "gcc" -version = "0.3.55" +name = "http-body" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737" +dependencies = [ + "bytes 1.0.1", + "http", + "pin-project-lite", +] [[package]] name = "httparse" -version = "1.3.3" +version = "1.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" + +[[package]] +name = "httpdate" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.10.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" +dependencies = [ + "base64 0.9.3", + "httparse", + "language-tags", + "log 0.3.9", + "mime", + "num_cpus", + "time", + "traitobject", + "typeable", + "unicase", + "url", +] [[package]] name = "hyper" -version = "0.10.15" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1" dependencies = [ - "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 1.0.1", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project", + "tokio", + "tower-service", + "tracing", + "want", ] [[package]] name = "idna" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", + "unicode-bidi", + "unicode-normalization", ] [[package]] name = "iovec" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "kernel32-sys" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "language-tags" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" [[package]] name = "lazy_static" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.46" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" [[package]] name = "libudev" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "libudev-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "libudev-sys", ] [[package]] name = "libudev-sys" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "pkg-config", +] + +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", ] [[package]] name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.14", ] [[package]] name = "log" -version = "0.4.6" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", ] [[package]] name = "mach" -version = "0.0.5" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "mach" -version = "0.1.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.1.2" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "mime" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" +dependencies = [ + "log 0.3.9", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "adler", + "autocfg 1.0.1", +] + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log 0.4.14", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +dependencies = [ + "lazy_static", + "libc", + "log 0.4.14", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", ] [[package]] name = "nix" -version = "0.10.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0eaf8df8bab402257e0a5c17a254e4cc1f72a93588a1ddfb5d356c801aa7cb" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", + "void", ] [[package]] name = "num_cpus" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] +[[package]] +name = "object" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + [[package]] name = "openssl" -version = "0.9.24" +version = "0.10.33" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" dependencies = [ - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", ] +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + [[package]] name = "openssl-sys" -version = "0.9.40" +version = "0.9.61" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.1", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api", + "parking_lot_core", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "rustc_version", + "smallvec", + "winapi 0.3.9", ] [[package]] name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + +[[package]] +name = "pin-project" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc174859768806e91ae575187ada95c91a29e96a98dc5d2cd9a1fed039501ba6" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a490329918e856ed1b083f244e3bfe2d8c4f336407e4ea9e1a9f479ff09049e5" +dependencies = [ + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.14" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "proc-macro2" -version = "0.4.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.1", ] [[package]] name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "0.6.10" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand" -version = "0.3.22" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.9", ] [[package]] name = "rand" -version = "0.4.5" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", +] + +[[package]] +name = "rand_core" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2", ] [[package]] name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_hc" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "redox_syscall" -version = "0.1.50" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] [[package]] name = "regex" -version = "0.2.11" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ - "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.5.6" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.9", ] [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rustc_version" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] [[package]] name = "ryu" -version = "0.2.7" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "safemem" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.9", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "security-framework" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.84" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" [[package]] name = "serde_derive" -version = "1.0.84" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", ] [[package]] name = "serde_json" -version = "1.0.34" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa", + "ryu", + "serde", ] [[package]] name = "serialport" -version = "2.3.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22f37409d980045734250d679750bdf11bd875fec5bb5417dd21bb75d04d31a1" dependencies = [ - "CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "IOKit-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "CoreFoundation-sys", + "IOKit-sys", + "bitflags", + "cfg-if 0.1.10", + "libudev", + "mach 0.2.3", + "nix", + "regex", + "winapi 0.3.9", ] [[package]] -name = "sha1" -version = "0.2.0" +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] [[package]] name = "syn" version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15", + "synom", + "unicode-xid 0.0.4", ] [[package]] name = "syn" -version = "0.15.24" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote 1.0.9", + "unicode-xid 0.2.1", ] [[package]] name = "synom" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4", ] [[package]] name = "tempfile" -version = "2.2.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "libc", + "rand 0.8.3", + "redox_syscall 0.2.5", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", ] [[package]] name = "thread-control" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea" [[package]] -name = "thread_local" -version = "0.3.6" +name = "time" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "wasi", + "winapi 0.3.9", ] [[package]] -name = "time" -version = "0.1.42" +name = "tinyvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" +dependencies = [ + "autocfg 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "tokio-codec" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ - "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12", + "futures", + "tokio-io", +] + +[[package]] +name = "tokio-executor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" +dependencies = [ + "crossbeam-utils", + "futures", +] + +[[package]] +name = "tokio-io" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +dependencies = [ + "bytes 0.4.12", + "futures", + "log 0.4.14", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" +dependencies = [ + "crossbeam-utils", + "futures", + "lazy_static", + "log 0.4.14", + "mio", + "num_cpus", + "parking_lot", + "slab", + "tokio-executor", + "tokio-io", + "tokio-sync", +] + +[[package]] +name = "tokio-sync" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +dependencies = [ + "fnv", + "futures", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +dependencies = [ + "bytes 0.4.12", + "futures", + "iovec", + "mio", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "tokio-tls" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" +dependencies = [ + "futures", + "native-tls", + "tokio-io", ] [[package]] name = "toml" -version = "0.4.10" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" dependencies = [ - "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", ] [[package]] name = "traitobject" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typeable" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" [[package]] -name = "ucd-util" -version = "0.1.3" +name = "typenum" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicase" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5", ] [[package]] name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" dependencies = [ - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", ] [[package]] name = "unicode-normalization" -version = "0.1.7" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +dependencies = [ + "tinyvec", +] [[package]] name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" [[package]] name = "unicode-xid" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "url" version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" dependencies = [ - "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "idna", + "matches", + "percent-encoding", ] [[package]] -name = "utf8-ranges" -version = "1.0.2" +name = "vcpkg" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] -name = "vcpkg" -version = "0.2.6" +name = "version_check" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" [[package]] name = "version_check" -version = "0.1.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log 0.4.14", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "websocket" -version = "0.19.2" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723abe6b75286edc51d8ecabb38a2353f62a9e9b0588998b59111474f1dcd637" dependencies = [ - "base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12", + "futures", + "hyper 0.10.16", + "native-tls", + "rand 0.6.5", + "tokio-codec", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-tls", + "unicase", + "url", + "websocket-base", +] + +[[package]] +name = "websocket-base" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f3fd505ff930da84156389639932955fb09705b3dccd1a3d60c8e7ff62776" +dependencies = [ + "base64 0.10.1", + "bitflags", + "byteorder", + "bytes 0.4.12", + "futures", + "native-tls", + "rand 0.6.5", + "sha-1", + "tokio-codec", + "tokio-io", + "tokio-tcp", + "tokio-tls", ] [[package]] name = "websocket_serial_server" version = "0.2.0" dependencies = [ - "argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "debug_stub_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "serialport 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thread-control 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "websocket 0.19.2 (registry+https://github.com/rust-lang/crates.io-index)", + "argparse", + "base64 0.13.0", + "daemonize", + "debug_stub_derive", + "env_logger", + "error-chain", + "hyper 0.14.5", + "log 0.4.14", + "rand 0.8.3", + "serde", + "serde_derive", + "serde_json", + "serialport", + "tempfile", + "thread-control", + "toml", + "websocket", ] [[package]] name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[metadata] -"checksum CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e9889e6db118d49d88d84728d0e964d973a5680befb5f85f55141beea5c20b" -"checksum IOKit-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "99696c398cbaf669d2368076bdb3d627fb0ce51a26899d7c61228c5c0af3bf4a" -"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" -"checksum argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47" -"checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" -"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" -"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557" -"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" -"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "40ade3d27603c2cb345eb0912aec461a6dec7e06a4ae48589904e808335c7afa" -"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" -"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" -"checksum daemonize 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0239832c1b4ca406d5ec73728cf4c7336d25cf85dd32db9e047e9e706ee0e935" -"checksum debug_stub_derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "496b7f8a2f853313c3ca370641d7ff3e42c32974fdccda8f0684599ed0a3ff6b" -"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" -"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" -"checksum hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)" = "df0caae6b71d266b91b4a83111a61d2b94ed2e2bea024c532b933dcff867e58c" -"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" -"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)" = "023a4cd09b2ff695f9734c1934145a315594b7986398496841c7031a5a1bbdbd" -"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe" -"checksum libudev-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum mach 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "196697f416cf23cf0d3319cf5b2904811b035c82df1dfec2117fb457699bf277" -"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" -"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" -"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -"checksum nix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fd5681d13fda646462cfbd4e5f2051279a89a544d50eb98c365b507246839f" -"checksum num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238" -"checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" -"checksum openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)" = "1bb974e77de925ef426b6bc82fce15fd45bdcbeb5728bffcfc7cdeeb7ce1c2d6" -"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" -"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" -"checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" -"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" -"checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" -"checksum serde_derive 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d6115a3ca25c224e409185325afc16a0d5aaaabc15c42b09587d6f1ba39a5b" -"checksum serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "bdf540260cfee6da923831f4776ddc495ada940c30117977c70f1313a6130545" -"checksum serialport 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "426edd50ed1192f9fb2405b713583567b85ac801fafb7476252ad7d7b1509453" -"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.15.24 (registry+https://github.com/rust-lang/crates.io-index)" = "734ecc29cd36e8123850d9bf21dfd62ef8300aaa8f879aabaa899721808be37c" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0" -"checksum thread-control 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" -"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum websocket 0.19.2 (registry+https://github.com/rust-lang/crates.io-index)" = "004a6a4bcc225ab013b0552d723e9d672a455c461151e7ee191dc3483dcb856e" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/Cargo.toml b/Cargo.toml index fe19dc8..b71fddd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,25 +8,25 @@ readme = "README.md" license-file = "LICENSE" [dependencies] -argparse = "0.2.1" -base64 = "0.5.1" -daemonize = "0.2.3" +argparse = "0.2.2" +base64 = "0.13.0" +daemonize = "0.4.1" debug_stub_derive = "0.3.0" -env_logger = "0.4.2" -error-chain = "0.10.0" -hyper = "0.10.9" -log = "0.3.7" -rand = "0.3.15" -serde = "1.0.2" -serde_derive = "1.0.2" -serde_json = "1.0.2" -serialport = "2.3.0" +env_logger = "0.8.3" +error-chain = "0.12.4" +hyper = "0.14.5" +log = "0.4.14" +rand = "0.8.3" +serde = "1.0.125" +serde_derive = "1.0.125" +serde_json = "1.0.64" +serialport = "4.0.0" thread-control = "0.1.2" -toml = "0.4.1" -websocket = "0.19.1" +toml = "0.5.8" +websocket = "0.26.2" [dev-dependencies] -tempfile = "2.1.5" +tempfile = "3.2.0" [lib] name="lib" diff --git a/README.md b/README.md index aa16124..0c19e1b 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,7 @@ Once Websocket-rs moves to tokio, this limitation can be removed #### Linux -1. `sudo apt-get install libudev-dev` -1. `sudo apt-get install libssl-dev` -1. `sudo apt-get install pkg-config` +1. `sudo apt-get install -y libudev-dev libssl-dev pkg-config` #### Windows diff --git a/rustfmt.toml b/rustfmt.toml index a564429..8b2d06a 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,7 +1,7 @@ +edition = "2018" +merge_derives = true +reorder_imports = true +reorder_modules = true tab_spaces = 2 -fn_args_layout = "Block" -array_layout = "Block" -control_style = "Rfc" -where_style = "Rfc" -generics_indent = "Block" -fn_call_style = "Block" \ No newline at end of file +use_field_init_shorthand = true +use_try_shorthand = true diff --git a/src/lib/cfg.rs b/src/lib/cfg.rs index 91c237c..c7aadb8 100644 --- a/src/lib/cfg.rs +++ b/src/lib/cfg.rs @@ -101,8 +101,8 @@ impl TomlWsssConfig { TomlWsssConfig { http_port: port, - ws_port: ws_port, - bind_address: bind_address, + ws_port, + bind_address, } } @@ -373,5 +373,4 @@ mod tests { cfg_str, contents ); } - } diff --git a/src/lib/dynamic_sleep.rs b/src/lib/dynamic_sleep.rs index 0bc4a2c..b31fef2 100644 --- a/src/lib/dynamic_sleep.rs +++ b/src/lib/dynamic_sleep.rs @@ -6,7 +6,7 @@ use std::thread; use std::time::{Duration, Instant}; -use log::LogLevel::Warn; +use log::Level::Warn; /// Dynamic Sleep /// The dynamic sleep struct diff --git a/src/lib/manager.rs b/src/lib/manager.rs index 003dc7d..8a6c8d8 100644 --- a/src/lib/manager.rs +++ b/src/lib/manager.rs @@ -47,8 +47,8 @@ impl Manager { writelock_manager: WriteLockManager::new(), port_manager: PortManager::new(), sub_manager: SubscriptionManager::new(), - receiver: receiver, - subsc_receiver: subsc_receiver, + receiver, + subsc_receiver, } } diff --git a/src/lib/port_manager.rs b/src/lib/port_manager.rs index 35c0f87..a7fb0df 100644 --- a/src/lib/port_manager.rs +++ b/src/lib/port_manager.rs @@ -49,7 +49,7 @@ impl PortManager { } /// Has the port been opened - pub fn is_port_open(&self, port_name: &String) -> bool { + pub fn is_port_open(&self, port_name: &str) -> bool { self.open_ports.contains_key(port_name) } @@ -59,20 +59,18 @@ impl PortManager { } /// Open a port - pub fn open_port(&mut self, port_name: &String) -> Result<()> { + pub fn open_port(&mut self, port_name: &str) -> Result<()> { if self.is_port_open(port_name) { Ok(()) } else { - let sp_settings = sp::SerialPortSettings { - baud_rate: sp::BaudRate::Baud115200, - data_bits: sp::DataBits::Eight, - flow_control: sp::FlowControl::None, - parity: sp::Parity::None, - stop_bits: sp::StopBits::One, - timeout: Duration::from_millis(1), - }; - - match sp::open_with_settings(&port_name, &sp_settings) { + let builder = sp::new(port_name, 115200) + .data_bits(sp::DataBits::Eight) + .flow_control(sp::FlowControl::None) + .parity(sp::Parity::None) + .stop_bits(sp::StopBits::One) + .timeout(Duration::from_millis(1)); + + match builder.open() { Ok(serial_port) => { let open_port = OpenPort { port: serial_port }; self.open_ports.insert(port_name.to_string(), open_port); @@ -84,13 +82,13 @@ impl PortManager { } /// Close a port - pub fn close_port(&mut self, port_name: &String) { + pub fn close_port(&mut self, port_name: &str) { // This drops the underlying serial port and box self.open_ports.remove(port_name); } /// Write data to the port - pub fn write_port(&mut self, port_name: &String, data: &[u8]) -> Result<()> { + pub fn write_port(&mut self, port_name: &str, data: &[u8]) -> Result<()> { match self.open_ports.get_mut(port_name) { None => Err(ErrorKind::OpenPortNotFound(port_name.to_string()).into()), Some(p) => p.write_port(data), @@ -100,7 +98,7 @@ impl PortManager { /// Read data from a port into the buffer buff /// If successful, returns Ok(usize) which is the number of /// bytes read - pub fn read_port(&mut self, port_name: &String, buff: &mut [u8]) -> Result { + pub fn read_port(&mut self, port_name: &str, buff: &mut [u8]) -> Result { match self.open_ports.get_mut(port_name) { None => Err(ErrorKind::OpenPortNotFound(port_name.to_string()).into()), Some(p) => p.read_port(buff), @@ -153,8 +151,8 @@ mod tests { use std::io::Read; use std::io::Write; - use serialport::posix::TTYPort; use serialport::SerialPort; + use serialport::TTYPort; use super::*; @@ -169,7 +167,7 @@ mod tests { let serial_msg = "abcdefg"; - if let Some(s_name) = slave.port_name() { + if let Some(s_name) = slave.name() { let mut port_manager = PortManager::new(); port_manager diff --git a/src/lib/sub_manager.rs b/src/lib/sub_manager.rs index 47f1d02..71dc9f5 100644 --- a/src/lib/sub_manager.rs +++ b/src/lib/sub_manager.rs @@ -285,5 +285,4 @@ mod tests { should_not_get_a_msg(&sub1_channel.1, "Subscriber 1"); should_not_get_a_msg(&sub2_channel.1, "Subscriber 2"); } - } diff --git a/src/lib/writelock_manager.rs b/src/lib/writelock_manager.rs index 6cd8fd1..094584a 100644 --- a/src/lib/writelock_manager.rs +++ b/src/lib/writelock_manager.rs @@ -218,5 +218,4 @@ mod tests { check_not_locked_by_anyone(&wl_manager, &port, vec![&sub_id1, &sub_id2, &sub_id3]); // TODO: Finish testing all other methods } - } From 6f06da65bd9ab3545493e74c5ecd27329103de15 Mon Sep 17 00:00:00 2001 From: Daniel Joyce Date: Fri, 2 Apr 2021 19:48:27 -0700 Subject: [PATCH 02/13] Remove travis --- .travis.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3df847d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: rust - -os: linux - -# Doesn't seem to do much. -# Always rebuilds everything. -# cache: cargo - -before_install: - - sudo apt-get install libudev-dev - -rust: - - nightly - - stable - -matrix: - fast_finish: true - allow_failures: - - rust: nightly - -script: - - cargo build --verbose - - RUST_BACKTRACE=1 cargo test --verbose From 2f41bea12602371275a1e2207968337773018b99 Mon Sep 17 00:00:00 2001 From: Daniel Joyce Date: Fri, 2 Apr 2021 19:48:46 -0700 Subject: [PATCH 03/13] Cleanup, formatting tweaks, etc --- src/lib/manager.rs | 2 +- src/lib/port_manager.rs | 3 +-- src/lib/writelock_manager.rs | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/manager.rs b/src/lib/manager.rs index 8a6c8d8..9a27094 100644 --- a/src/lib/manager.rs +++ b/src/lib/manager.rs @@ -194,7 +194,7 @@ impl Manager { self.check_sub_id(&sub_id)?; self .writelock_manager - .lock_port(&port_name, &sub_id) + .try_lock_port(&port_name, &sub_id) .map(|_| self.send_message(&sub_id, SerialResponse::WriteLocked { port: port_name })) } diff --git a/src/lib/port_manager.rs b/src/lib/port_manager.rs index a7fb0df..3e0c558 100644 --- a/src/lib/port_manager.rs +++ b/src/lib/port_manager.rs @@ -1,5 +1,4 @@ use std::collections::{HashMap, HashSet}; -use std::error::Error; use std::iter::FromIterator; use std::time::Duration; @@ -12,7 +11,7 @@ struct OpenPort { /// The opened serial port /// SerialPort is not Sized, so it makes hashmap mad /// and so we deal with these shennanigans - port: Box, + port: Box, } impl OpenPort { diff --git a/src/lib/writelock_manager.rs b/src/lib/writelock_manager.rs index 094584a..7234f05 100644 --- a/src/lib/writelock_manager.rs +++ b/src/lib/writelock_manager.rs @@ -95,7 +95,7 @@ impl WriteLockManager { } /// Try and lock the port - pub fn lock_port(&mut self, port_name: &String, sub_id: &String) -> Result<()> { + pub fn try_lock_port(&mut self, port_name: &String, sub_id: &String) -> Result<()> { match self.is_port_locked_by_someone_else(port_name, sub_id) { false => { self @@ -172,7 +172,7 @@ mod tests { assert_eq!( true, wl_manager - .lock_port(&port, &sub_id1) + .try_lock_port(&port, &sub_id1) .map(|_| true) .unwrap_or(false), "Sub_id '{}' locking port '{}' should succeed", @@ -185,7 +185,7 @@ mod tests { assert_eq!( true, wl_manager - .lock_port(&port, &sub_id2) + .try_lock_port(&port, &sub_id2) .map(|_| false) .unwrap_or(true), "Sub_id '{}' locking port '{}' should fail", From 83a9702cf13ab47b1fdd32518db04249e91d5846 Mon Sep 17 00:00:00 2001 From: Daniel Joyce Date: Sat, 3 Apr 2021 21:57:58 -0700 Subject: [PATCH 04/13] Bring in new dependencies * Will use Figment for config * Bring in hyper, tungstenite * Bring in anyhow, thiserror for error handling * Bring in tokio, async-trait for new async stuff --- Cargo.lock | 907 ++++++++++++++--------------------------------------- Cargo.toml | 11 +- 2 files changed, 237 insertions(+), 681 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 445b8d5..547baf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,12 +45,38 @@ dependencies = [ "memchr", ] +[[package]] +name = "anyhow" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" + [[package]] name = "argparse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47" +[[package]] +name = "async-trait" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" +dependencies = [ + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", +] + +[[package]] +name = "atomic" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" +dependencies = [ + "autocfg", +] + [[package]] name = "atty" version = "0.2.14" @@ -59,15 +85,9 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", + "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.1" @@ -88,25 +108,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - [[package]] name = "base64" version = "0.13.0" @@ -121,53 +122,25 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - [[package]] name = "boxfnonce" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5988cb1d626264ac94100be357308f29ff7cbdd3b36bda27f450a4ee3f713426" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "1.0.1" @@ -193,40 +166,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "cpuid-bool" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.0.1", - "cfg-if 0.1.10", - "lazy_static", -] +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "daemonize" @@ -250,9 +193,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ "generic-array", ] @@ -265,7 +208,7 @@ checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ "atty", "humantime", - "log 0.4.14", + "log", "regex", "termcolor", ] @@ -277,14 +220,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ "backtrace", - "version_check 0.9.3", + "version_check", ] [[package]] -name = "fake-simd" -version = "0.1.2" +name = "figment" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +checksum = "0ca029e813a72b7526d28273d25f3e4a2f365d1b7a1018a6f93ec9053a119763" +dependencies = [ + "atomic", + "serde", + "uncased", + "version_check", +] [[package]] name = "fnv" @@ -293,48 +242,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" +name = "form_urlencoded" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ - "bitflags", - "fuchsia-zircon-sys", + "matches", + "percent-encoding", ] -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures-channel" version = "0.3.13" @@ -350,6 +266,12 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +[[package]] +name = "futures-sink" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" + [[package]] name = "futures-task" version = "0.3.13" @@ -363,18 +285,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" dependencies = [ "futures-core", + "futures-sink", "futures-task", "pin-project-lite", "pin-utils", + "slab", ] [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", + "version_check", ] [[package]] @@ -409,7 +334,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 1.0.1", + "bytes", "fnv", "itoa", ] @@ -420,7 +345,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfb77c123b4e2f72a2069aeae0b4b4949cc7e966df277813fc16347e7549737" dependencies = [ - "bytes 1.0.1", + "bytes", "http", "pin-project-lite", ] @@ -443,32 +368,13 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "0.10.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" -dependencies = [ - "base64 0.9.3", - "httparse", - "language-tags", - "log 0.3.9", - "mime", - "num_cpus", - "time", - "traitobject", - "typeable", - "unicase", - "url", -] - [[package]] name = "hyper" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf09f61b52cfcf4c00de50df88ae423d6c02354e385a86341133b5338630ad1" dependencies = [ - "bytes 1.0.1", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -484,11 +390,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-tungstenite" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8caf279e78ecd352de6e0568e24cf4e70292e649fa1a9065850172d46f7c804" +dependencies = [ + "base64", + "hyper", + "pin-project", + "sha-1", + "tokio", + "tokio-tungstenite", +] + [[package]] name = "idna" -version = "0.1.5" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" dependencies = [ "matches", "unicode-bidi", @@ -496,35 +416,28 @@ dependencies = [ ] [[package]] -name = "iovec" -version = "0.1.4" +name = "input_buffer" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" dependencies = [ - "libc", + "bytes", ] [[package]] -name = "itoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "instant" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "cfg-if 1.0.0", ] [[package]] -name = "language-tags" -version = "0.2.2" +name = "itoa" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "lazy_static" @@ -560,22 +473,13 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.3.4" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.14", -] - [[package]] name = "log" version = "0.4.14" @@ -609,27 +513,12 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" -[[package]] -name = "mime" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" -dependencies = [ - "log 0.3.9", -] - [[package]] name = "miniz_oxide" version = "0.4.4" @@ -637,67 +526,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg", ] [[package]] name = "mio" -version = "0.6.23" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", "libc", - "log 0.4.14", + "log", "miow", - "net2", - "slab", - "winapi 0.2.8", + "ntapi", + "winapi", ] [[package]] name = "miow" -version = "0.2.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "native-tls" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" -dependencies = [ - "lazy_static", - "libc", - "log 0.4.14", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -713,6 +564,15 @@ dependencies = [ "void", ] +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -737,74 +597,40 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "openssl" -version = "0.10.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.61" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" -dependencies = [ - "autocfg 1.0.1", - "cc", - "libc", - "pkg-config", - "vcpkg", -] +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parking_lot" -version = "0.9.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ + "instant", "lock_api", "parking_lot_core", - "rustc_version", ] [[package]] name = "parking_lot_core" -version = "0.6.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", + "cfg-if 1.0.0", + "instant", "libc", - "redox_syscall 0.1.57", - "rustc_version", + "redox_syscall", "smallvec", - "winapi 0.3.9", + "winapi", ] [[package]] name = "percent-encoding" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project" @@ -874,25 +700,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.8.3" @@ -900,19 +707,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha 0.3.0", - "rand_core 0.6.2", - "rand_hc 0.3.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -922,24 +719,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core 0.6.2", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.6.2" @@ -949,92 +731,15 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core 0.6.2", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", + "rand_core", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.5" @@ -1067,7 +772,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1076,81 +781,18 @@ version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "security-framework" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3670b1d2fdf6084d192bc71ead7aabe6c06aa2ea3fbd9cc3ac111fa5c2b1bd84" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3676258fd3cfe2c9a0ec99ce3038798d847ce3e4bb17746373eb9f0f1ac16339" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.125" @@ -1193,21 +835,31 @@ dependencies = [ "mach 0.2.3", "nix", "regex", - "winapi 0.3.9", + "winapi", ] [[package]] name = "sha-1" -version = "0.8.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" dependencies = [ "block-buffer", + "cfg-if 1.0.0", + "cpuid-bool", "digest", - "fake-simd", "opaque-debug", ] +[[package]] +name = "signal-hook-registry" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +dependencies = [ + "libc", +] + [[package]] name = "slab" version = "0.4.2" @@ -1216,12 +868,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "0.6.14" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "syn" @@ -1262,10 +911,10 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if 1.0.0", "libc", - "rand 0.8.3", - "redox_syscall 0.2.5", + "rand", + "redox_syscall", "remove_dir_all", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1278,22 +927,31 @@ dependencies = [ ] [[package]] -name = "thread-control" -version = "0.1.2" +name = "thiserror" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" +dependencies = [ + "thiserror-impl", +] [[package]] -name = "time" -version = "0.1.44" +name = "thiserror-impl" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ - "libc", - "wasi", - "winapi 0.3.9", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", ] +[[package]] +name = "thread-control" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea" + [[package]] name = "tinyvec" version = "1.1.1" @@ -1315,94 +973,42 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" dependencies = [ - "autocfg 1.0.1", - "pin-project-lite", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures", - "tokio-io", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures", - "log 0.4.14", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils", - "futures", - "lazy_static", - "log 0.4.14", + "autocfg", + "bytes", + "libc", + "memchr", "mio", "num_cpus", + "once_cell", "parking_lot", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "winapi", ] [[package]] -name = "tokio-tcp" -version = "0.1.4" +name = "tokio-macros" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" dependencies = [ - "bytes 0.4.12", - "futures", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", ] [[package]] -name = "tokio-tls" -version = "0.2.1" +name = "tokio-tungstenite" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" +checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2" dependencies = [ - "futures", - "native-tls", - "tokio-io", + "futures-util", + "log", + "pin-project", + "tokio", + "tungstenite", ] [[package]] @@ -1440,12 +1046,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" - [[package]] name = "try-lock" version = "0.2.3" @@ -1453,10 +1053,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] -name = "typeable" -version = "0.1.2" +name = "tungstenite" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" +checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "input_buffer", + "log", + "rand", + "sha-1", + "thiserror", + "url", + "utf-8", +] [[package]] name = "typenum" @@ -1465,12 +1079,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] -name = "unicase" -version = "1.4.2" +name = "uncased" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" +checksum = "300932469d646d39929ffe84ad5c1837beecf602519ef5695e485b472de4082b" dependencies = [ - "version_check 0.1.5", + "version_check", ] [[package]] @@ -1505,26 +1119,21 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "url" -version = "1.7.2" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ + "form_urlencoded", "idna", "matches", "percent-encoding", ] [[package]] -name = "vcpkg" -version = "0.2.11" +name = "utf-8" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" [[package]] name = "version_check" @@ -1544,7 +1153,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ - "log 0.4.14", + "log", "try-lock", ] @@ -1554,76 +1163,34 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" -[[package]] -name = "websocket" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723abe6b75286edc51d8ecabb38a2353f62a9e9b0588998b59111474f1dcd637" -dependencies = [ - "bytes 0.4.12", - "futures", - "hyper 0.10.16", - "native-tls", - "rand 0.6.5", - "tokio-codec", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-tls", - "unicase", - "url", - "websocket-base", -] - -[[package]] -name = "websocket-base" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403f3fd505ff930da84156389639932955fb09705b3dccd1a3d60c8e7ff62776" -dependencies = [ - "base64 0.10.1", - "bitflags", - "byteorder", - "bytes 0.4.12", - "futures", - "native-tls", - "rand 0.6.5", - "sha-1", - "tokio-codec", - "tokio-io", - "tokio-tcp", - "tokio-tls", -] - [[package]] name = "websocket_serial_server" version = "0.2.0" dependencies = [ + "anyhow", "argparse", - "base64 0.13.0", + "async-trait", + "base64", "daemonize", "debug_stub_derive", "env_logger", "error-chain", - "hyper 0.14.5", - "log 0.4.14", - "rand 0.8.3", + "figment", + "hyper", + "hyper-tungstenite", + "log", + "rand", "serde", "serde_derive", "serde_json", "serialport", "tempfile", + "thiserror", "thread-control", + "tokio", "toml", - "websocket", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -1634,12 +1201,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1652,7 +1213,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1660,13 +1221,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] diff --git a/Cargo.toml b/Cargo.toml index b71fddd..781230b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,29 +8,34 @@ readme = "README.md" license-file = "LICENSE" [dependencies] +anyhow = "1.0.40" argparse = "0.2.2" +async-trait = "0.1.48" base64 = "0.13.0" daemonize = "0.4.1" debug_stub_derive = "0.3.0" env_logger = "0.8.3" error-chain = "0.12.4" +figment = "0.10.5" hyper = "0.14.5" +hyper-tungstenite = "0.3.1" log = "0.4.14" rand = "0.8.3" serde = "1.0.125" serde_derive = "1.0.125" serde_json = "1.0.64" serialport = "4.0.0" +thiserror = "1.0.24" thread-control = "0.1.2" +tokio = { version = "1.4.0", features = ["full"] } toml = "0.5.8" -websocket = "0.26.2" [dev-dependencies] tempfile = "3.2.0" [lib] -name="lib" -path="src/lib/mod.rs" +name = "lib" +path = "src/lib/mod.rs" [[bin]] name = "wsss" From 6397fa3206417e1a46e317f694235da50ba46fd2 Mon Sep 17 00:00:00 2001 From: Daniel Joyce Date: Sat, 3 Apr 2021 22:01:54 -0700 Subject: [PATCH 05/13] Move errors to use thiserror and anyhow * Fix up impact on other modules --- src/lib/errors.rs | 125 ++++++++++++----------------------- src/lib/manager.rs | 34 +++++----- src/lib/messages.rs | 3 +- src/lib/mod.rs | 2 - src/lib/port_manager.rs | 35 ++++++---- src/lib/sub_manager.rs | 41 ++++++++---- src/lib/writelock_manager.rs | 8 +-- 7 files changed, 114 insertions(+), 134 deletions(-) diff --git a/src/lib/errors.rs b/src/lib/errors.rs index fbb321a..901caa9 100644 --- a/src/lib/errors.rs +++ b/src/lib/errors.rs @@ -1,87 +1,48 @@ use crate::messages::{SerialRequest, SerialResponse}; +use anyhow; +use thiserror::Error; -error_chain! { +/// The kinds of errors that WebsocketSerialServer can return +#[derive(Error, Debug)] +pub enum WebsocketSerialServerError { + /// Unknown server request + #[error("Unknown request")] + UnknownRequest, + /// Open port not found + #[error("Open port '{port}' not found")] + OpenPortNotFound { port: String }, + #[error("Subscription '{subscription_id}' not found")] + /// Subscription not found + SubscriptionNotFound { subscription_id: String }, + /// Port already write locked error + #[error("Port '{port}' is already writelocked")] + AlreadyWriteLocked { port: String }, + /// Need write lock error + #[error("Port '{port}' needs to be writelocked before writing")] + NeedWriteLock { port: String }, + /// Serial port read error + #[error("Port '{port}' had read error")] + PortReadError { port: String }, + /// Serial Port EOF error + #[error("Port '{port}' EOF")] + PortEofError { port: String }, + /// Serial port write error + #[error("Port '{port}' write error")] + PortWriteError { port: String }, + /// Send to subscriber error + #[error("Failed send to subscriber '{subscription_id}'")] + SubscriberSendError { subscription_id: String }, + /// Catchall for all others + #[error(transparent)] + Other(#[from] anyhow::Error), +} - foreign_links { - // Wrapped Format error - Fmt(::std::fmt::Error); - // Wrapped IO error - Io(::std::io::Error) #[cfg(unix)]; - // Wrapped serial port error - Serialport(::serialport::Error) #[cfg(unix)]; - // Wrapped Ut8 decode error - Utf8(::std::string::FromUtf8Error); - // Wrapped json error - Json(::serde_json::error::Error); - // Wrapped toml deserialization error - TomlDeserialize(::toml::de::Error); - // Wrapped toml serialization error - TomlSerialize(::toml::ser::Error); - // Wrapped sync send response error - SendResponse(::std::sync::mpsc::SendError); - // Wrapped Base64 decode error - Base64(::base64::DecodeError); - // Wrapped sync send request error - SendRequest(::std::sync::mpsc::SendError<(String,SerialRequest)>); - // wrapped send websocket error. - SendWsMessage(::websocket::result::WebSocketError); - // Wrapped ipv4 parse error - IpAddr(::std::net::AddrParseError); - } +pub type Result = std::result::Result; - errors{ - /// Unknown server request - UnknownRequest{ - description("Unknown request") - display("Unknown request,") - } - /// Open port not found - OpenPortNotFound(port:String){ - description("Open serial port not found") - display("Serial port '{}' not found, try opening it first", port) - } - /// Subscription not found - SubscriptionNotFound(sub_id:String){ - description("Subscription not found") - display("Subscription for id '{}' not found", sub_id) - } - /// Port already write locked error - AlreadyWriteLocked(port:String){ - description("Port already write locked by another client") - display("Open serial port '{}' is already write locked by another client", port) - } - /// Need write lock error - NeedWriteLock(port:String){ - description("Need write lock") - display("Write to open port '{}' failed, you need to write lock first", port) - } - /// Serial port read error - PortReadError(port:String){ - description("Error reading serial port") - display("Read from port '{}' failed", port) +impl From for SerialResponse { + fn from(wss_error: WebsocketSerialServerError) -> Self { + SerialResponse::Error{ + error: wss_error.to_string() + } } - /// Serial Port EOF error - PortEOFError(port:String){ - description("Encountered EOF reading serial port") - display("Encountered EOF reading serial port {}", port) - } - /// Serial port write error - PortWriteError(port:String){ - description("Error writing serial port") - display("Writing to port '{}' failed", port) - } - /// Send to subscriber error - SubscriberSendError(sub_id:String){ - description("Error sending message to subscriber") - display("Send to subscriber '{}' failed", sub_id) - } - } -} - -/// Convert Error to serial response error enum type -pub fn to_serial_response_error(err: Error) -> SerialResponse { - SerialResponse::Error { - description: err.description().to_string(), - display: format!("{}", err), - } -} +} \ No newline at end of file diff --git a/src/lib/manager.rs b/src/lib/manager.rs index 9a27094..cf9e07b 100644 --- a/src/lib/manager.rs +++ b/src/lib/manager.rs @@ -1,6 +1,5 @@ -//! Manages serial port state and communication with clients, -//! and handling requests / responses - +/// Manages serial port state and communication with clients, +/// and handling requests / responses use std::collections::HashSet; use std::sync::mpsc::{Receiver, TryRecvError}; use std::thread; @@ -163,7 +162,7 @@ impl Manager { if let Err(e) = response { warn!("Error '{}' occured handling serial request message", e); // Send error? - self.send_message(&sub_id, to_serial_response_error(e)); + self.send_message(&sub_id, e.into()); } } @@ -179,7 +178,7 @@ impl Manager { self.check_owns_writelock(&port_name, &sub_id)?; match base_64 { true => base64::decode(&data) - .map_err(|e| ErrorKind::Base64(e).into()) + .map_err(|e| WebsocketSerialServerError::Other(e.into())) .and_then(|d| self.port_manager.write_port(&port_name, &d)) .map(|_| self.send_message(&sub_id, SerialResponse::Wrote { port: port_name })), false => self @@ -244,14 +243,10 @@ impl Manager { .port_manager .list_ports() .map(|v| v.iter().map(|v| v.port_name.clone()).collect()); - let resp = port_names.map(|pns| SerialResponse::List { ports: pns }); - self.send_message( - &sub_id, - resp.unwrap_or(SerialResponse::Error { - display: "".to_string(), - description: "".to_string(), - }), - ); + match port_names.map(|pns| SerialResponse::List { ports: pns }){ + Ok(response) => self.send_message(&sub_id, response), + Err(error) => self.send_message(&sub_id, error.into()) + } Ok(()) } @@ -306,8 +301,10 @@ impl Manager { fn cleanup_bad_ports(&mut self, bad_ports: &HashSet) { for port_name in bad_ports.iter() { // Tell everyone port is sick - let err_resp = - to_serial_response_error(ErrorKind::PortReadError(port_name.to_owned()).into()); + let err_resp: SerialResponse = WebsocketSerialServerError::PortReadError { + port: port_name.clone(), + } + .into(); self.broadcast_message_for_port(port_name, err_resp); // Tell everyone the sick ports were closed let close_resp = SerialResponse::Closed { @@ -348,9 +345,12 @@ impl Manager { } /// Cleanup any bad subs where a message send failed - fn cleanup_bad_subs(&mut self, bad_subs: Vec) { + fn cleanup_bad_subs(&mut self, bad_subs: Vec) { for e in bad_subs { - if let Error(ErrorKind::SubscriberSendError(sub_id), _) = e { + if let WebsocketSerialServerError::SubscriberSendError { + subscription_id: ref sub_id, + } = e + { // Remove subscriptions self.sub_manager.end_subscription(&sub_id); // Remove all write locks held by dead subscription diff --git a/src/lib/messages.rs b/src/lib/messages.rs index 0fdc58d..ae28232 100644 --- a/src/lib/messages.rs +++ b/src/lib/messages.rs @@ -125,8 +125,7 @@ pub enum SerialResponse { /// /// ``` Error { - description: String, - display: String, + error: String }, /// Data that was read from port /// diff --git a/src/lib/mod.rs b/src/lib/mod.rs index 1dc58dc..73b2629 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -8,8 +8,6 @@ #![allow(unused_variables)] extern crate argparse; #[macro_use] -extern crate error_chain; -#[macro_use] extern crate log; #[macro_use] extern crate serde_derive; diff --git a/src/lib/port_manager.rs b/src/lib/port_manager.rs index 3e0c558..b5f4f93 100644 --- a/src/lib/port_manager.rs +++ b/src/lib/port_manager.rs @@ -2,6 +2,7 @@ use std::collections::{HashMap, HashSet}; use std::iter::FromIterator; use std::time::Duration; +use anyhow::anyhow; use serialport as sp; use crate::errors::*; @@ -21,7 +22,7 @@ impl OpenPort { .port .write_all(data) .and_then(|_| self.port.flush()) - .map_err(|err| ErrorKind::Io(err).into()) + .map_err(|error| WebsocketSerialServerError::Other(anyhow!(error))) } /// Read data from the serial port @@ -29,7 +30,7 @@ impl OpenPort { self .port .read(buff) - .map_err(|err| ErrorKind::Io(err).into()) + .map_err(|error| WebsocketSerialServerError::Other(anyhow!(error))) } } @@ -54,7 +55,7 @@ impl PortManager { /// List all serial ports pub fn list_ports(&self) -> Result> { - sp::available_ports().map_err(|e| ErrorKind::Serialport(e).into()) + Ok(sp::available_ports().map_err(|error| WebsocketSerialServerError::Other(anyhow!(error)))?) } /// Open a port @@ -75,7 +76,7 @@ impl PortManager { self.open_ports.insert(port_name.to_string(), open_port); Ok(()) } - Err(e) => Err(ErrorKind::Serialport(e).into()), + Err(error) => Err(WebsocketSerialServerError::Other(anyhow!(error))), } } } @@ -89,7 +90,9 @@ impl PortManager { /// Write data to the port pub fn write_port(&mut self, port_name: &str, data: &[u8]) -> Result<()> { match self.open_ports.get_mut(port_name) { - None => Err(ErrorKind::OpenPortNotFound(port_name.to_string()).into()), + None => Err(WebsocketSerialServerError::OpenPortNotFound { + port: port_name.to_owned(), + }), Some(p) => p.write_port(data), } } @@ -99,7 +102,9 @@ impl PortManager { /// bytes read pub fn read_port(&mut self, port_name: &str, buff: &mut [u8]) -> Result { match self.open_ports.get_mut(port_name) { - None => Err(ErrorKind::OpenPortNotFound(port_name.to_string()).into()), + None => Err(WebsocketSerialServerError::OpenPortNotFound { + port: port_name.to_owned(), + }), Some(p) => p.read_port(buff), } } @@ -117,20 +122,24 @@ impl PortManager { info!("Received EOF reading from port {}", port_name); map.insert( port_name.to_string(), - Err(ErrorKind::PortEOFError(port_name.clone()).into()), + Err(WebsocketSerialServerError::PortEofError { + port: port_name.to_owned(), + }), ); } else { let bytes = buffer[0..bytes_read].to_vec(); map.insert(port_name.to_string(), Ok(bytes)); } } - Err(e) => { - // debug!("Error {} reading from port {}", e, port_name); - match e.description() { - "Operation timed out" => {} - _ => { - map.insert(port_name.to_string(), Err(e.into())); + Err(error) => { + if let WebsocketSerialServerError::Other(error) = error { + if let Ok(serial_port_error) = error.downcast::() { + // Nop case + } else { + map.insert(port_name.to_string(), Err(error.into())); } + } else { + map.insert(port_name.to_string(), Err(error.into())); } } } diff --git a/src/lib/sub_manager.rs b/src/lib/sub_manager.rs index 71dc9f5..31ed425 100644 --- a/src/lib/sub_manager.rs +++ b/src/lib/sub_manager.rs @@ -1,6 +1,8 @@ use std::collections::{HashMap, HashSet}; use std::sync::mpsc::Sender; +use anyhow::anyhow; + use crate::errors::*; use crate::messages::*; @@ -15,10 +17,12 @@ struct Subscription { impl Subscription { /// Send a message to a subscriber fn send_message(&self, msg: SerialResponse) -> Result<()> { - self - .subscriber - .send(msg) - .map_err(|e| ErrorKind::SendResponse(e).into()) + Ok( + self + .subscriber + .send(msg) + .map_err(|e| WebsocketSerialServerError::Other(anyhow!(e)))?, + ) } /// Register interest in a port @@ -64,7 +68,9 @@ impl SubscriptionManager { sub.add_port(port_name); Ok(()) } - None => Err(ErrorKind::SubscriptionNotFound(sub_id.to_string()).into()), + None => Err(WebsocketSerialServerError::SubscriptionNotFound { + subscription_id: sub_id.to_owned(), + }), } } @@ -75,7 +81,9 @@ impl SubscriptionManager { sub.ports.retain(|p| p != port_name); Ok(()) } - None => Err(ErrorKind::SubscriptionNotFound(sub_id.to_string()).into()), + None => Err(WebsocketSerialServerError::SubscriptionNotFound { + subscription_id: sub_id.to_owned(), + }), } } @@ -118,7 +126,9 @@ impl SubscriptionManager { pub fn check_subscription_exists(&self, sub_id: &String) -> Result<()> { match self.subscriptions.contains_key(sub_id) { true => Ok(()), - false => Err(ErrorKind::SubscriptionNotFound(sub_id.to_string()).into()), + false => Err(WebsocketSerialServerError::SubscriptionNotFound { + subscription_id: sub_id.to_owned(), + }), } } @@ -130,17 +140,16 @@ impl SubscriptionManager { /// Send a message to the given subscription pub fn send_message(&self, sub_id: &String, msg: SerialResponse) -> Result<()> { match self.subscriptions.get(sub_id) { - None => Err(ErrorKind::SubscriptionNotFound(sub_id.to_string()).into()), - Some(sub) => sub - .subscriber - .send(msg) - .map_err(|e| ErrorKind::SendResponse(e).into()), + None => Err(WebsocketSerialServerError::SubscriptionNotFound { + subscription_id: sub_id.to_owned(), + }), + Some(sub) => Ok(sub.subscriber.send(msg).map_err(|e| WebsocketSerialServerError::Other(anyhow!(e)))?), } } /// Broadcast a messages to all subscribers, returning /// a vec of (sub_id,ErrorKind::SendResponse) failures if some sends fail - pub fn broadcast_message(&self, msg: SerialResponse) -> Vec { + pub fn broadcast_message(&self, msg: SerialResponse) -> Vec { debug!("Broadcasting '{}' to all subscribers", &msg); let mut res = Vec::new(); for (sub_id, sub) in self.subscriptions.iter() { @@ -153,7 +162,11 @@ impl SubscriptionManager { } /// Broadcast message to all subscribers registered for a given port - pub fn broadcast_message_for_port(&self, port_name: &String, msg: SerialResponse) -> Vec { + pub fn broadcast_message_for_port( + &self, + port_name: &String, + msg: SerialResponse, + ) -> Vec { debug!( "Broadcasting '{}' to all subscribers registered on port {}", &msg, port_name diff --git a/src/lib/writelock_manager.rs b/src/lib/writelock_manager.rs index 7234f05..7c40024 100644 --- a/src/lib/writelock_manager.rs +++ b/src/lib/writelock_manager.rs @@ -41,10 +41,10 @@ impl WriteLockManager { /// return error pub fn check_owns_write_lock(&self, port_name: &String, sub_id: &String) -> Result<()> { match self.write_locks.get(port_name) { - None => Err(ErrorKind::NeedWriteLock(port_name.to_string()).into()), + None => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), Some(sid) => { if sid != sub_id { - Err(ErrorKind::AlreadyWriteLocked(port_name.to_string()).into()) + Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }) } else { Ok(()) } @@ -64,7 +64,7 @@ impl WriteLockManager { self.write_locks.remove(port_name); Ok(()) } - true => Err(ErrorKind::AlreadyWriteLocked(port_name.to_string()).into()), + true => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), } } @@ -103,7 +103,7 @@ impl WriteLockManager { .insert(port_name.to_string(), sub_id.to_string()); Ok(()) } - true => Err(ErrorKind::AlreadyWriteLocked(port_name.to_string()).into()), + true => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), } } } From 844b224bb706e9a94e027b36467bc5d55398635b Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sat, 3 Apr 2021 22:08:37 -0700 Subject: [PATCH 06/13] Remove imports, format --- src/lib/errors.rs | 2 +- src/lib/manager.rs | 4 ++-- src/lib/messages.rs | 4 +--- src/lib/sub_manager.rs | 7 ++++++- src/lib/writelock_manager.rs | 16 ++++++++++++---- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/lib/errors.rs b/src/lib/errors.rs index 901caa9..da8c12b 100644 --- a/src/lib/errors.rs +++ b/src/lib/errors.rs @@ -1,4 +1,4 @@ -use crate::messages::{SerialRequest, SerialResponse}; +use crate::messages::SerialResponse; use anyhow; use thiserror::Error; diff --git a/src/lib/manager.rs b/src/lib/manager.rs index cf9e07b..2fa22b6 100644 --- a/src/lib/manager.rs +++ b/src/lib/manager.rs @@ -243,9 +243,9 @@ impl Manager { .port_manager .list_ports() .map(|v| v.iter().map(|v| v.port_name.clone()).collect()); - match port_names.map(|pns| SerialResponse::List { ports: pns }){ + match port_names.map(|pns| SerialResponse::List { ports: pns }) { Ok(response) => self.send_message(&sub_id, response), - Err(error) => self.send_message(&sub_id, error.into()) + Err(error) => self.send_message(&sub_id, error.into()), } Ok(()) } diff --git a/src/lib/messages.rs b/src/lib/messages.rs index ae28232..2ff992d 100644 --- a/src/lib/messages.rs +++ b/src/lib/messages.rs @@ -124,9 +124,7 @@ pub enum SerialResponse { /// }} /// /// ``` - Error { - error: String - }, + Error { error: String }, /// Data that was read from port /// /// If the data could not be parsed into a utf8 string diff --git a/src/lib/sub_manager.rs b/src/lib/sub_manager.rs index 31ed425..90e384a 100644 --- a/src/lib/sub_manager.rs +++ b/src/lib/sub_manager.rs @@ -143,7 +143,12 @@ impl SubscriptionManager { None => Err(WebsocketSerialServerError::SubscriptionNotFound { subscription_id: sub_id.to_owned(), }), - Some(sub) => Ok(sub.subscriber.send(msg).map_err(|e| WebsocketSerialServerError::Other(anyhow!(e)))?), + Some(sub) => Ok( + sub + .subscriber + .send(msg) + .map_err(|e| WebsocketSerialServerError::Other(anyhow!(e)))?, + ), } } diff --git a/src/lib/writelock_manager.rs b/src/lib/writelock_manager.rs index 7c40024..7fbd884 100644 --- a/src/lib/writelock_manager.rs +++ b/src/lib/writelock_manager.rs @@ -41,10 +41,14 @@ impl WriteLockManager { /// return error pub fn check_owns_write_lock(&self, port_name: &String, sub_id: &String) -> Result<()> { match self.write_locks.get(port_name) { - None => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), + None => Err(WebsocketSerialServerError::AlreadyWriteLocked { + port: port_name.to_owned(), + }), Some(sid) => { if sid != sub_id { - Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }) + Err(WebsocketSerialServerError::AlreadyWriteLocked { + port: port_name.to_owned(), + }) } else { Ok(()) } @@ -64,7 +68,9 @@ impl WriteLockManager { self.write_locks.remove(port_name); Ok(()) } - true => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), + true => Err(WebsocketSerialServerError::AlreadyWriteLocked { + port: port_name.to_owned(), + }), } } @@ -103,7 +109,9 @@ impl WriteLockManager { .insert(port_name.to_string(), sub_id.to_string()); Ok(()) } - true => Err(WebsocketSerialServerError::AlreadyWriteLocked { port: port_name.to_owned() }), + true => Err(WebsocketSerialServerError::AlreadyWriteLocked { + port: port_name.to_owned(), + }), } } } From bfa75d261d56374594366f64884b9c69a3e7fe4b Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sun, 4 Apr 2021 22:04:28 -0700 Subject: [PATCH 07/13] Worked on new config system * Bring in struct opt for cli * Bring in Figment for multiple config source control * Change name to wssps to match with the full name * TODO Create proper multi format provider for Figment and remove panic * TODO Add config tests --- Cargo.lock | 178 +++++++++++++++++- Cargo.toml | 10 +- DOCUMENTATION.md | 12 +- README.md | 10 +- src/bin/main.rs | 16 +- src/lib/cfg.rs | 376 --------------------------------------- src/lib/configuration.rs | 93 ++++++++++ src/lib/dynamic_sleep.rs | 4 +- src/lib/errors.rs | 1 + src/lib/mod.rs | 2 +- src/lib/port_manager.rs | 11 +- 11 files changed, 306 insertions(+), 407 deletions(-) delete mode 100644 src/lib/cfg.rs create mode 100644 src/lib/configuration.rs diff --git a/Cargo.lock b/Cargo.lock index 547baf2..f77f85d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,6 +165,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "bitflags", + "textwrap", + "unicode-width", +] + [[package]] name = "cpuid-bool" version = "0.1.2" @@ -200,6 +211,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "env_logger" version = "0.8.3" @@ -230,7 +247,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ca029e813a72b7526d28273d25f3e4a2f365d1b7a1018a6f93ec9053a119763" dependencies = [ "atomic", + "pear", "serde", + "serde_json", + "serde_yaml", + "toml", "uncased", "version_check", ] @@ -319,6 +340,15 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -415,6 +445,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "inlinable_string" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" + [[package]] name = "input_buffer" version = "0.4.0" @@ -471,6 +507,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "lock_api" version = "0.4.2" @@ -626,6 +668,29 @@ dependencies = [ "winapi", ] +[[package]] +name = "pear" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ab3a2b792945ed67eadbbdcbd2898f8dd2319392b2a45ac21adea5245cb113" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620c9c4776ba41b59ab101360c9b1419c0c8c81cd2e6e39fae7109e7425994cb" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote 1.0.9", + "syn 1.0.68", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -676,6 +741,30 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote 1.0.9", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.26" @@ -685,6 +774,19 @@ dependencies = [ "unicode-xid 0.2.1", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", + "version_check", + "yansi", +] + [[package]] name = "quote" version = "0.3.15" @@ -821,6 +923,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + [[package]] name = "serialport" version = "4.0.0" @@ -872,6 +986,30 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "structopt" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", +] + [[package]] name = "syn" version = "0.11.11" @@ -926,6 +1064,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.24" @@ -1105,6 +1252,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + [[package]] name = "unicode-xid" version = "0.0.4" @@ -1164,7 +1323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] -name = "websocket_serial_server" +name = "websocket_serial_port_server" version = "0.2.0" dependencies = [ "anyhow", @@ -1184,11 +1343,11 @@ dependencies = [ "serde_derive", "serde_json", "serialport", + "structopt", "tempfile", "thiserror", "thread-control", "tokio", - "toml", ] [[package]] @@ -1221,3 +1380,18 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "yansi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" diff --git a/Cargo.toml b/Cargo.toml index 781230b..7836c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2018" -name = "websocket_serial_server" +name = "websocket_serial_port_server" version = "0.2.0" authors = ["Daniel Joyce "] description = "A websocket server providing access to local serial ports" @@ -16,7 +16,7 @@ daemonize = "0.4.1" debug_stub_derive = "0.3.0" env_logger = "0.8.3" error-chain = "0.12.4" -figment = "0.10.5" +figment = { version = "0.10.5", features = ["env", "json", "toml", "yaml"] } hyper = "0.14.5" hyper-tungstenite = "0.3.1" log = "0.4.14" @@ -25,18 +25,18 @@ serde = "1.0.125" serde_derive = "1.0.125" serde_json = "1.0.64" serialport = "4.0.0" +structopt = { version = "0.3", default-features = false } thiserror = "1.0.24" thread-control = "0.1.2" tokio = { version = "1.4.0", features = ["full"] } -toml = "0.5.8" [dev-dependencies] tempfile = "3.2.0" [lib] -name = "lib" +name = "wssps" path = "src/lib/mod.rs" [[bin]] -name = "wsss" +name = "wssps" path = "src/bin/main.rs" diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index e0a7da2..b55cee4 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -2,7 +2,7 @@ ## Configuration -wsss supports configuration in several different ways, by commandline parameters, env variables, and config files +wssps supports configuration in several different ways, by commandline parameters, env variables, and config files commandline options override env variables, which overrides file based config. @@ -12,11 +12,11 @@ Currently the following values may be specified * `ws_port` The port the websocket listens on, defaults to 10081 * `bind_address` The ip address the server binds to, defaults to 127.0.0.1 ( localhost ) -When wsss starts, it first tries to load configuration information from the following files: +When wssps starts, it first tries to load configuration information from the following files: 1. The file specified by the environment variable `WSS_CONF_FILE` -1. It then tries to load the file in `/etc/wsss/wsss_conf.toml` -1. It then tries to load a `wsss_conf.toml` file located in the same directory as the wsss executable +1. It then tries to load the file in `/etc/wssps/wssps_conf.toml` +1. It then tries to load a `wssps_conf.toml` file located in the same directory as the wssps executable **Only the first file found is loaded.** @@ -40,13 +40,13 @@ The following env variable names are searched: Finally it parses and uses any configuration passed in via commandline arguments -Available commandline arguments can be found via running `wsss -h` or `wsss --help` +Available commandline arguments can be found via running `wssps -h` or `wssps --help` sample output: ``` Usage: - ./target/debug/wsss [OPTIONS] + ./target/debug/wssps [OPTIONS] Provide access to serial ports over JSON Websockets diff --git a/README.md b/README.md index 0c19e1b..f1eddd6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# websocket-serial-server (wsss) +# websocket-serial-server (wssps) [![Build Status](https://travis-ci.org/DanielJoyce/websocket-serial-server.svg?branch=master)](https://travis-ci.org/DanielJoyce/websocket-serial-server) @@ -41,7 +41,7 @@ such use case, this is fine. Once Websocket-rs moves to tokio, this limitation can be removed -*There is no support for custom protocol or buffer handlers.* That should be handled by client libraries. The purpose of wsss is to simply get data from a serial port to clients and vice-versa. +*There is no support for custom protocol or buffer handlers.* That should be handled by client libraries. The purpose of wssps is to simply get data from a serial port to clients and vice-versa. ## Developing @@ -91,7 +91,7 @@ build: run: -`./target/debug/wsss`, or if built with `--release`, `./target/release/wsss` +`./target/debug/wssps`, or if built with `--release`, `./target/release/wssps` use `-p` or `--port` to set http port (default is 8080) @@ -99,11 +99,11 @@ then browse to `http://localhost:PORT` to find the test page. ### Logging -Wsss makes extensive use of logging and the [env_logger](https://crates.io/crates/env_logger) crate +Wssps makes extensive use of logging and the [env_logger](https://crates.io/crates/env_logger) crate Please read the env_logger docs for more information, but here is a quick example: -```RUST_LOG=debug ./target/debug/wsss``` +```RUST_LOG=debug ./target/debug/wssps``` ## TODO diff --git a/src/bin/main.rs b/src/bin/main.rs index 385b6dd..6129d67 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -7,7 +7,7 @@ //! //! ## Running //! -//! ```./wsss``` +//! ```./wssps``` //! //! For information on configuration please check out //! the [cfg](../lib/cfg/index.html) package in serialsupport @@ -34,24 +34,24 @@ use websocket::result::WebSocketError; use websocket::server::upgrade::WsUpgrade; use websocket::{Message, Server}; -use lib::cfg::*; -use lib::dynamic_sleep::DynamicSleep; -use lib::errors as e; -use lib::manager::Manager; -use lib::messages::*; +use wssps::cfg::*; +use wssps::dynamic_sleep::DynamicSleep; +use wssps::errors as e; +use wssps::manager::Manager; +use wssps::messages::*; /// Max number of failures we allow when trying to send /// data to client before exiting /// TODO: Make configurable pub const MAX_SEND_ERROR_COUNT: u32 = 5; -/// Launches wsss +/// Launches wssps pub fn main() { // Init logger env_logger::init().expect("Initialization of logging system failed!"); // Grab config - let cfg = WsssConfig::load(); + let cfg = WsspsConfig::load(); // html file for landing page let websocket_html = include_str!("websockets.html").replace( diff --git a/src/lib/cfg.rs b/src/lib/cfg.rs deleted file mode 100644 index c7aadb8..0000000 --- a/src/lib/cfg.rs +++ /dev/null @@ -1,376 +0,0 @@ -//! Loads and centralizes configuration from -//! config files, env, and command line -//! -//! For information on command line switches, config files, -//! or env names, check the documentation for [WsssConfig](struct.WsssConfig.html) - -use std::convert::Into; -use std::default::Default; -use std::env; -use std::fs::File; -use std::io::prelude::*; -use std::net::Ipv4Addr; -use std::str::FromStr; - -use argparse::{ArgumentParser, StoreOption}; -use toml; - -use crate::errors::*; - -/// Default HTTP port to bind to if none given -pub const DEFAULT_HTTP_PORT: u32 = 10080; -/// Default Websocket port to bind to if none given -pub const DEFAULT_WS_PORT: u32 = 10081; -/// Default ip address to bind -pub const DEFAULT_BIND_ADDR: &str = "127.0.0.1"; - -/// Suported config file extensions -pub const SUPPORTED_EXTENSIONS: &[&str] = &["toml"]; -/// Config file base name -pub const CONFIG_FILE_NAME: &str = "wsss_conf.toml"; - -/// Env variable name for specifying a config file -pub const CONF_FILE_ENV_KEY: &str = "WSSS_CONF_FILE"; -/// Env variable name for specifying address to bind -pub const BIND_ADDRESS_ENV_KEY: &str = "WSSS_BIND_ADDRESS"; -/// Env variable name for specifying HTTP port -pub const HTTP_PORT_ENV_KEY: &str = "WSSS_HTTP_PORT"; -/// Env variable name for specifying WS port -pub const WS_PORT_ENV_KEY: &str = "WSSS_WS_PORT"; - -const HTTP_PORT_KEY: &str = "http_port"; -const WS_PORT_KEY: &str = "ws_port"; -const BIND_ADDRESS_KEY: &str = "bind_address"; - -/// This struct models partially specified configuration, -/// leaving unset values as None -#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)] -struct TomlWsssConfig { - pub http_port: Option, - pub ws_port: Option, - pub bind_address: Option, -} - -impl TomlWsssConfig { - /// Convert to a WsssConfig with default values - /// substituted for missing values - pub fn to_config(self) -> Result { - let addr_string: String = self.bind_address.unwrap_or(DEFAULT_BIND_ADDR.to_string()); - - let ip_addr = Ipv4Addr::from_str(&addr_string)?; - // .map_err(|e| ErrorKind::IpAddr(e).into())?; - - Ok(WsssConfig { - http_port: self.http_port.unwrap_or(DEFAULT_HTTP_PORT), - ws_port: self.ws_port.unwrap_or(DEFAULT_WS_PORT), - bind_address: ip_addr, - }) - } - - /// Merge partial configuration read from different sources - pub fn merge>(self, other: T) -> TomlWsssConfig { - let o = other.into(); - TomlWsssConfig { - http_port: merge_options(self.http_port, o.http_port), - ws_port: merge_options(self.ws_port, o.ws_port), - bind_address: merge_options(self.bind_address, o.bind_address), - } - } - - /// Parse the command line returning a config with - /// defaults overridden by commandline values. - pub fn parse_cmdline() -> TomlWsssConfig { - let mut port: Option = None; - let mut ws_port: Option = None; - let mut bind_address: Option = None; - - { - let mut ap = ArgumentParser::new(); - ap.set_description("Provide access to serial ports over JSON Websockets"); - ap.refer(&mut port) - .add_option(&["-p", "--http_port"], StoreOption, "Http Port"); - ap.refer(&mut ws_port) - .add_option(&["-w", "--ws_port"], StoreOption, "Websocket Port"); - ap.refer(&mut bind_address).add_option( - &["-a", "--bind_address"], - StoreOption, - "Bind Address", - ); - ap.parse_args_or_exit(); - } - - TomlWsssConfig { - http_port: port, - ws_port, - bind_address, - } - } - - /// Parse a file to yield a partial config - pub fn parse_file(file_name: &str) -> Result { - let mut file = File::open(file_name)?; - let mut contents = String::new(); - file.read_to_string(&mut contents)?; - let toml_cfg: TomlWsssConfig = toml::from_str(&contents)?; - Ok(toml_cfg) - } - - /// Save partial config to a file - pub fn save_to_file(&self, file_name: &str) -> Result<()> { - let mut file = File::open(file_name)?; - let cfg_toml = toml::to_string(self)?; - file.write_all(cfg_toml.as_bytes())?; - file.flush()?; - Ok(()) - } - - /// Parse configuration out of env variables. - /// See the cfg::*_ENV_KEY values - pub fn parse_env() -> TomlWsssConfig { - TomlWsssConfig { - http_port: env::var(HTTP_PORT_ENV_KEY) - .ok() - .and_then(|v| v.parse::().ok()), - ws_port: env::var(WS_PORT_ENV_KEY) - .ok() - .and_then(|v| v.parse::().ok()), - bind_address: env::var(BIND_ADDRESS_ENV_KEY).ok(), - } - } -} - -/// Convert a WsssConfig to a TomlWsssConfig -impl From for TomlWsssConfig { - fn from(wsss_cfg: WsssConfig) -> TomlWsssConfig { - TomlWsssConfig { - http_port: Some(wsss_cfg.http_port), - ws_port: Some(wsss_cfg.ws_port), - bind_address: Some(wsss_cfg.bind_address.to_string()), - } - } -} - -/// Merge o2 into o1, only if o2 is missing a value for a particular key -fn merge_options(o1: Option, o2: Option) -> Option { - match (o1, o2) { - (None, Some(v2)) => Some(v2), - (None, None) => None, - (Some(v1), _) => Some(v1), - } -} - -/// Config is a struct storing global -/// configuration information derived -/// from commandline, file, and env -/// variables -/// -/// Sample toml config: -/// -/// ``` toml -/// http_port = 8080 -/// ws_port = 8082 -/// bind_address = "10.1.100.12" -/// ``` -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct WsssConfig { - /// The http_port to listen on. - /// - /// Defaults to 10080 - /// - /// env var WSSS_HTTP_PORT - /// - /// cmdline switch -p or --http_port - pub http_port: u32, - - /// The ws port to listen on. - /// - /// defaults to http_port + 1 - /// - /// env var WSSS_WS_PORT - /// - /// cmdline switch -w or --ws_port - pub ws_port: u32, - - /// Address to bind to. - /// - /// Defaults to 127.0.0.1 (localhost) - /// - /// env var WSSS_BIND_ADDR - /// - /// cmdline -a or --bind_address - pub bind_address: Ipv4Addr, -} - -impl WsssConfig { - /// Try and load configuration from several well known sources - /// command line arguments, and env vars - /// - /// First we try and load a toml config file - /// specified by the environment variable `WSSS_CONF_FILE`. - /// - /// If not found, we then try loading `/etc/wsss/wsss_conf.toml`. - /// - /// If not found we then try and load a wsss_conf.toml from the - /// directory wsss was launched from. - /// - /// Only the contents of the first file found will be loaded - /// and then modified by env and commandline variables - /// - /// Then for any settings loaded from the file, we override them - /// with any env vars we find, then override with any commandline - /// parameters - pub fn load() -> WsssConfig { - let file_cfg = load_env_file() - .or_else(|| load_etc()) - .or_else(|| load_local_file()) - .unwrap_or(TomlWsssConfig::default()); - - let env_cfg = TomlWsssConfig::parse_env(); - - let cmdline_cfg = TomlWsssConfig::parse_cmdline(); - - return TomlWsssConfig::merge( - cmdline_cfg, - TomlWsssConfig::merge( - env_cfg, - TomlWsssConfig::merge(file_cfg, WsssConfig::default()), - ), - ) - .into(); - } - - /// Save the configuration to a file - pub fn save_to_file(&self, file_name: &str) -> Result<()> { - let mut file = File::open(file_name)?; - let cfg_toml = toml::to_string(self)?; - file.write_all(cfg_toml.as_bytes())?; - file.flush()?; - Ok(()) - } -} - -/// Provide a default configuration -/// filled out with default values -impl Default for WsssConfig { - /// Create a WsssConfig with all values - /// set to default - fn default() -> WsssConfig { - WsssConfig { - http_port: DEFAULT_HTTP_PORT, - ws_port: DEFAULT_WS_PORT, - bind_address: Ipv4Addr::from_str(DEFAULT_BIND_ADDR).unwrap(), - } - } -} - -/// Convert a TomlWsssConfig to a fully filled out -/// WsssConfig replacing None with default values -impl From for WsssConfig { - fn from(toml_wsss_cfg: TomlWsssConfig) -> WsssConfig { - let addr_string: String = toml_wsss_cfg - .bind_address - .unwrap_or(DEFAULT_BIND_ADDR.to_string()); - - let ip_addr = Ipv4Addr::from_str(&addr_string).unwrap(); - - WsssConfig { - http_port: toml_wsss_cfg.http_port.unwrap_or(DEFAULT_HTTP_PORT), - ws_port: toml_wsss_cfg.ws_port.unwrap_or(DEFAULT_WS_PORT), - bind_address: ip_addr, - } - } -} - -/// Try a load config from /etc on unices -#[cfg(unix)] -fn load_etc() -> Option { - TomlWsssConfig::parse_file(&format!("/etc/wsss/{}", CONFIG_FILE_NAME)).ok() -} - -/// Dummy method for loading etc config on windows -#[cfg(not(unix))] -fn load_etc() -> Option { - None -} - -/// Try and and load a config file -/// specified by the env variable cfg::CONF_FILE_ENV_KEY -fn load_env_file() -> Option { - env::var(CONF_FILE_ENV_KEY) - .ok() - .and_then(|file_name| TomlWsssConfig::parse_file(&file_name).ok()) -} - -/// Try and load config from same directory as executable -fn load_local_file() -> Option { - env::current_exe() - .ok() - .and_then(|mut dir| { - dir.pop(); - Some(dir) - }) - .and_then(|file| TomlWsssConfig::parse_file(&file.to_string_lossy()).ok()) -} - -#[cfg(test)] -mod tests { - - extern crate tempfile; - - use std::io::SeekFrom; - - use self::tempfile::*; - use super::*; - - #[test] - fn toml_wsss_config_default() { - let cfg = TomlWsssConfig::default(); - assert_eq!(cfg.http_port, None, "Http port should be None"); - assert_eq!(cfg.ws_port, None, "WS port should be None"); - assert_eq!(cfg.bind_address, None, "bind address should be None"); - } - - #[test] - fn wsss_config_default() { - let cfg = WsssConfig::default(); - let def_bind_addr = Ipv4Addr::from_str(DEFAULT_BIND_ADDR).unwrap(); - assert_eq!( - cfg.http_port, DEFAULT_HTTP_PORT, - "Http port should be '{}'", - DEFAULT_HTTP_PORT - ); - assert_eq!( - cfg.ws_port, DEFAULT_WS_PORT, - "WS port should be '{}'", - DEFAULT_WS_PORT - ); - assert_eq!( - cfg.bind_address, def_bind_addr, - "bind address should be '{}'", - DEFAULT_BIND_ADDR - ); - } - - #[test] - fn test_file_config() { - let mut tmp_cfg_file = tempfile().expect("Creating temp file failed"); - let cfg = WsssConfig { - http_port: 12345, - ws_port: 12346, - bind_address: Ipv4Addr::from_str("10.1.100.10").expect("Create config obj failed"), - }; - let cfg_str = toml::to_string(&cfg).expect("Serializing to toml failed"); - tmp_cfg_file.write_all(cfg_str.as_bytes()).unwrap(); - tmp_cfg_file.flush().unwrap(); - tmp_cfg_file.seek(SeekFrom::Start(0)).unwrap(); - let mut contents = String::new(); - tmp_cfg_file.read_to_string(&mut contents).unwrap(); - let toml_cfg: TomlWsssConfig = toml::from_str(&contents).unwrap(); - let read_cfg = WsssConfig::from(toml_cfg); - assert_eq!( - cfg, read_cfg, - "Configuration '{}' should equal '{}'", - cfg_str, contents - ); - } -} diff --git a/src/lib/configuration.rs b/src/lib/configuration.rs new file mode 100644 index 0000000..f0caabd --- /dev/null +++ b/src/lib/configuration.rs @@ -0,0 +1,93 @@ +//! Loads and centralizes configuration from +//! config files, env, and command line +//! +//! For information on command line switches, config files, +//! or env names, check the documentation for [WsspsConfig](struct.WsspsConfig.html) +//! +//! TODO: Tls Support + +use std::{net::Ipv4Addr, path::PathBuf}; + +use structopt::StructOpt; + +use figment::providers::*; +use figment::Figment; + +/// Default HTTP port to bind to if none given +pub const DEFAULT_PORT: u32 = 10080; +/// Default ip address to bind +pub const DEFAULT_ADDRESS: &str = "127.0.0.1"; + +/// Suported config file extensions +pub const SUPPORTED_EXTENSIONS: &[&str] = &["toml", "json", "yaml"]; + +/// Config file base name +pub const CONFIG_FILE_NAME_PREFIX: &str = "wssps_conf"; + +/// Configuration settings. +#[derive(Clone, Debug, Serialize, Deserialize, StructOpt)] +#[structopt(name = "wssps", about = "WebSocket Serial Port Server")] +pub struct WsspsConfigCli { + /// The port to listen on. + #[structopt(short, long, help = "port to bind to")] + pub port: Option, + + /// Address to bind to. + #[structopt(short, long, help = "address to bind")] + pub address: Option, + + /// Configuration file to use + #[structopt(short = "f", long = "config-file", help = "address to bind")] + pub configuration_file: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct WsspsConfig { + /// The port to listen on. + pub port: u32, + + /// Address to bind to. + pub address: Ipv4Addr, +} +impl WsspsConfig { + fn get() -> Self { + let cli_args: WsspsConfigCli = WsspsConfigCli::from_args(); + + // Pull from CLI, fill holes with env + let figment = Figment::from(Serialized::defaults(cli_args)).join(Env::prefixed("WSSPS_")); + + let env_args: WsspsConfigCli = figment + .extract() + .expect("Failed to load config from environment args"); // Shouldn't happen + + let figment = match env_args.configuration_file { + Some(configuration_file) => figment.join_file(configuration_file), + None => figment, + }; + + figment + .extract::() + .expect("Failed to parse configuration") + } +} + +// TODO Makes this a true provider instead of panicing. +pub trait FigmentExt { + fn join_file(self, file_path: PathBuf) -> Figment; +} + +impl FigmentExt for Figment { + fn join_file(self, file_path: PathBuf) -> Figment { + match file_path + .extension() + .expect("Could determine config file type") + .to_string_lossy() + .as_ref() + { + "yaml" | "yml" => self.join(Yaml::file(file_path)), + "json" => self.join(Yaml::file(file_path)), + "toml" => self.join(Yaml::file(file_path)), + _ => panic!("Format not supported") + } + } +} diff --git a/src/lib/dynamic_sleep.rs b/src/lib/dynamic_sleep.rs index b31fef2..adf14b2 100644 --- a/src/lib/dynamic_sleep.rs +++ b/src/lib/dynamic_sleep.rs @@ -85,6 +85,8 @@ impl DynamicSleep { let subsec_nanos = dur.subsec_nanos(); self.last_instant = Some(now); if dur.as_secs() > 0 || subsec_nanos > self._period_nanos { + // Count more accurately, slips of X seconds should count more. + // At 33 hz, 1 sec of slippage = 33 slips... self.slips += 1; return; } else { @@ -94,7 +96,7 @@ impl DynamicSleep { // If we have had slippage within the last second ( approx ) // then we log it. if log_enabled!(Warn) { - warn!("'{}' slipped {} times in last second", self.tag, self.slips); + warn!("'{}' slipped {} times", self.tag, self.slips); } self.slips = 0; self.cycles = 0; diff --git a/src/lib/errors.rs b/src/lib/errors.rs index da8c12b..8b72a8d 100644 --- a/src/lib/errors.rs +++ b/src/lib/errors.rs @@ -3,6 +3,7 @@ use anyhow; use thiserror::Error; /// The kinds of errors that WebsocketSerialServer can return +/// TODO Rename to WsspsError #[derive(Error, Debug)] pub enum WebsocketSerialServerError { /// Unknown server request diff --git a/src/lib/mod.rs b/src/lib/mod.rs index 73b2629..a3a3386 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -12,7 +12,7 @@ extern crate log; #[macro_use] extern crate serde_derive; -pub mod cfg; +pub mod configuration; pub mod common; pub mod dynamic_sleep; pub mod errors; diff --git a/src/lib/port_manager.rs b/src/lib/port_manager.rs index b5f4f93..bb6fd15 100644 --- a/src/lib/port_manager.rs +++ b/src/lib/port_manager.rs @@ -132,9 +132,14 @@ impl PortManager { } } Err(error) => { - if let WebsocketSerialServerError::Other(error) = error { - if let Ok(serial_port_error) = error.downcast::() { - // Nop case + if let WebsocketSerialServerError::Other(ref other_error) = error { + if let Some(serial_port_error) = other_error.downcast_ref::() { + match serial_port_error.description.as_str() { + "Operation timed out" => {} //Nop + _ => { + map.insert(port_name.to_string(), Err(error.into())); + } + } } else { map.insert(port_name.to_string(), Err(error.into())); } From 6692219551029ed123df21a3cd04acc7a762ba86 Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sat, 10 Apr 2021 10:19:29 -0700 Subject: [PATCH 08/13] Cleaned up docs, but needs to be rewritten --- DOCUMENTATION.md | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index b55cee4..70b0102 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -8,15 +8,12 @@ commandline options override env variables, which overrides file based config. Currently the following values may be specified -* `http_port` The HTTP port to bind to, defaults to 10080 -* `ws_port` The port the websocket listens on, defaults to 10081 -* `bind_address` The ip address the server binds to, defaults to 127.0.0.1 ( localhost ) +* `port` The HTTP /WS port to bind to, defaults to 10080 +* `address` The ip address the server binds to, defaults to 127.0.0.1 ( localhost ) When wssps starts, it first tries to load configuration information from the following files: -1. The file specified by the environment variable `WSS_CONF_FILE` -1. It then tries to load the file in `/etc/wssps/wssps_conf.toml` -1. It then tries to load a `wssps_conf.toml` file located in the same directory as the wssps executable +TODO UPDATE **Only the first file found is loaded.** @@ -25,39 +22,22 @@ The configuration file makes use of [TOML](https://github.com/toml-lang/toml). H ``` toml # Sample config. Hashes mark comments -http_port = 10090 -ws_port = 10095 -bind_address = "10.1.101.26" +port = 10090 +address = "10.1.101.26" ``` Next, it tries to pull in config from the environment. These values will override any values found in any loaded configuration files. The following env variable names are searched: -* `WSSS_HTTP_PORT` Specifies the HTTP port -* `WSSS_WS_PORT` Specifies the Websocket port -* `WSSS_BIND_ADDRESS` Specifies the ip address to bind to +* `WSSPS_PORT` Specifies the HTTP/WS port +* `WSSPS_ADDRESS` Specifies the ip address to bind to Finally it parses and uses any configuration passed in via commandline arguments Available commandline arguments can be found via running `wssps -h` or `wssps --help` -sample output: - -``` -Usage: - ./target/debug/wssps [OPTIONS] - -Provide access to serial ports over JSON Websockets - -optional arguments: - -h,--help show this help message and exit - -p,--http_port HTTP_PORT - Http Port - -w,--ws_port WS_PORT Websocket Port - -a,--bind_address BIND_ADDRESS - Bind Address -``` +TODO UPDATE Finally, any item not specified in any of these steps is given the default value mentioned at the beginning of this section. From 747a48e7e7bbb848c6bbb82bfddb3e45c2d8850a Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sat, 10 Apr 2021 16:51:32 -0700 Subject: [PATCH 09/13] Fix config handling * Properly merge from defaults, env and cli * If file is specified, merge that too --- Cargo.lock | 302 ++++++++++++++++++++++++++++++++++++++- Cargo.toml | 7 +- src/lib/configuration.rs | 109 ++++++++------ 3 files changed, 370 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f77f85d..03c4bbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anyhow" version = "1.0.40" @@ -165,6 +174,18 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "winapi", +] + [[package]] name = "clap" version = "2.33.3" @@ -192,6 +213,41 @@ dependencies = [ "libc", ] +[[package]] +name = "darling" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d6ddad5866bb2170686ed03f6839d31a76e5407d80b1c334a2c24618543ffa" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ced1fd13dc386d5a8315899de465708cf34ee2a6d9394654515214e67bb846" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote 1.0.9", + "strsim", + "syn 1.0.68", +] + +[[package]] +name = "darling_macro" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7a1445d54b2f9792e3b31a3e715feabbace393f38dc4ffd49d94ee9bc487d5" +dependencies = [ + "darling_core", + "quote 1.0.9", + "syn 1.0.68", +] + [[package]] name = "debug_stub_derive" version = "0.3.0" @@ -340,6 +396,31 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +[[package]] +name = "h2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc018e188373e2777d0ef2467ebff62a08e66c3f5857b23c8fbec3018210dc00" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + [[package]] name = "heck" version = "0.3.2" @@ -408,12 +489,14 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "httparse", "httpdate", "itoa", "pin-project", + "socket2", "tokio", "tower-service", "tracing", @@ -434,6 +517,12 @@ dependencies = [ "tokio-tungstenite", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.2.2" @@ -445,6 +534,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inlinable_string" version = "0.1.14" @@ -549,6 +648,15 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.8" @@ -615,6 +723,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.13.0" @@ -862,6 +989,16 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.23" @@ -877,12 +1014,31 @@ dependencies = [ "winapi", ] +[[package]] +name = "routerify" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c18f54182904acfbd8082adb04985c59eb037027105631e3a68a5a51de31294d" +dependencies = [ + "http", + "hyper", + "lazy_static", + "percent-encoding", + "regex", +] + [[package]] name = "rustc-demangle" version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +[[package]] +name = "rustversion" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" + [[package]] name = "ryu" version = "1.0.5" @@ -900,6 +1056,9 @@ name = "serde" version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" @@ -923,6 +1082,29 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e557c650adfb38b32a5aec07082053253c703bc3cec654b27a5dbcf61995bb9b" +dependencies = [ + "rustversion", + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48b35457e9d855d3dc05ef32a73e0df1e2c0fd72c38796a4ee909160c8eeec2" +dependencies = [ + "darling", + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", +] + [[package]] name = "serde_yaml" version = "0.8.17" @@ -965,6 +1147,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.3.0" @@ -986,6 +1177,22 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "socket2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "structopt" version = "0.3.21" @@ -1099,6 +1306,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea" +[[package]] +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", +] + [[package]] name = "tinyvec" version = "1.1.1" @@ -1158,6 +1374,20 @@ dependencies = [ "tungstenite", ] +[[package]] +name = "tokio-util" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5143d049e85af7fbc36f5454d990e62c2df705b3589f123b71f441b6b59f443f" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.8" @@ -1181,9 +1411,21 @@ checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +dependencies = [ + "proc-macro2", + "quote 1.0.9", + "syn 1.0.68", +] + [[package]] name = "tracing-core" version = "0.1.17" @@ -1193,6 +1435,59 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "try-lock" version = "0.2.3" @@ -1324,7 +1619,7 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" [[package]] name = "websocket_serial_port_server" -version = "0.2.0" +version = "0.2.0-dev" dependencies = [ "anyhow", "argparse", @@ -1339,15 +1634,20 @@ dependencies = [ "hyper-tungstenite", "log", "rand", + "routerify", "serde", "serde_derive", "serde_json", + "serde_with", "serialport", "structopt", "tempfile", "thiserror", "thread-control", "tokio", + "tracing", + "tracing-futures", + "tracing-subscriber", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7836c60..40a60fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2018" name = "websocket_serial_port_server" -version = "0.2.0" +version = "0.2.0-dev" authors = ["Daniel Joyce "] description = "A websocket server providing access to local serial ports" readme = "README.md" @@ -21,11 +21,16 @@ hyper = "0.14.5" hyper-tungstenite = "0.3.1" log = "0.4.14" rand = "0.8.3" +routerify = "2.0.0" serde = "1.0.125" +serde_with = "1.8.0" serde_derive = "1.0.125" serde_json = "1.0.64" serialport = "4.0.0" structopt = { version = "0.3", default-features = false } +tracing = "0.1" +tracing-futures = "0.2" +tracing-subscriber = "0.2" thiserror = "1.0.24" thread-control = "0.1.2" tokio = { version = "1.4.0", features = ["full"] } diff --git a/src/lib/configuration.rs b/src/lib/configuration.rs index f0caabd..f87a26c 100644 --- a/src/lib/configuration.rs +++ b/src/lib/configuration.rs @@ -6,17 +6,18 @@ //! //! TODO: Tls Support -use std::{net::Ipv4Addr, path::PathBuf}; - -use structopt::StructOpt; +use std::net::{IpAddr, Ipv4Addr}; +use std::path::PathBuf; use figment::providers::*; use figment::Figment; +use serde_with::skip_serializing_none; +use structopt::StructOpt; /// Default HTTP port to bind to if none given -pub const DEFAULT_PORT: u32 = 10080; +pub const DEFAULT_PORT: u16 = 10080; /// Default ip address to bind -pub const DEFAULT_ADDRESS: &str = "127.0.0.1"; +pub const DEFAULT_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); /// Suported config file extensions pub const SUPPORTED_EXTENSIONS: &[&str] = &["toml", "json", "yaml"]; @@ -25,69 +26,85 @@ pub const SUPPORTED_EXTENSIONS: &[&str] = &["toml", "json", "yaml"]; pub const CONFIG_FILE_NAME_PREFIX: &str = "wssps_conf"; /// Configuration settings. +#[skip_serializing_none] #[derive(Clone, Debug, Serialize, Deserialize, StructOpt)] #[structopt(name = "wssps", about = "WebSocket Serial Port Server")] pub struct WsspsConfigCli { - /// The port to listen on. - #[structopt(short, long, help = "port to bind to")] - pub port: Option, + /// The port to listen on. + #[structopt(short, long, help = "port to bind to")] + pub port: Option, - /// Address to bind to. - #[structopt(short, long, help = "address to bind")] - pub address: Option, + /// Address to bind to. + #[structopt(short, long, help = "address to bind")] + pub address: Option, - /// Configuration file to use - #[structopt(short = "f", long = "config-file", help = "address to bind")] - pub configuration_file: Option, + /// Configuration file to use + #[structopt(short = "f", long = "config-file", help = "address to bind")] + pub configuration_file: Option, } #[derive(Clone, Debug, Serialize, Deserialize)] pub struct WsspsConfig { - /// The port to listen on. - pub port: u32, + /// The port to listen on. + pub port: u16, - /// Address to bind to. - pub address: Ipv4Addr, + /// Address to bind to. + pub address: IpAddr, +} + +impl Default for WsspsConfig { + fn default() -> Self { + Self { + port: DEFAULT_PORT, + address: DEFAULT_ADDRESS + } + } } + impl WsspsConfig { - fn get() -> Self { - let cli_args: WsspsConfigCli = WsspsConfigCli::from_args(); + pub fn get() -> Self { + let cli_args: WsspsConfigCli = WsspsConfigCli::from_args(); - // Pull from CLI, fill holes with env - let figment = Figment::from(Serialized::defaults(cli_args)).join(Env::prefixed("WSSPS_")); + // Pull from CLI, fill holes with env + let figment_cli = Figment::from(Serialized::defaults(WsspsConfig::default())) + .merge(Env::prefixed("WSSPS_")) + .merge(Serialized::defaults(cli_args)); - let env_args: WsspsConfigCli = figment - .extract() - .expect("Failed to load config from environment args"); // Shouldn't happen + let env_args: WsspsConfigCli = figment_cli + .extract() + .expect("Failed to load config from environment args"); // Shouldn't happen - let figment = match env_args.configuration_file { - Some(configuration_file) => figment.join_file(configuration_file), - None => figment, - }; + // Should have all values filled + // let base_config: WsspsConfig = figment.extract().expect("Should not fail"); - figment - .extract::() - .expect("Failed to parse configuration") - } + let figment = match env_args.configuration_file { + Some(configuration_file) => Figment::from(figment_cli).join_file(configuration_file), + None => figment_cli, + }; + + figment + .extract::() + .expect("Failed to parse configuration") + } } // TODO Makes this a true provider instead of panicing. pub trait FigmentExt { - fn join_file(self, file_path: PathBuf) -> Figment; + fn join_file(self, file_path: PathBuf) -> Figment; } impl FigmentExt for Figment { - fn join_file(self, file_path: PathBuf) -> Figment { - match file_path - .extension() - .expect("Could determine config file type") - .to_string_lossy() - .as_ref() - { - "yaml" | "yml" => self.join(Yaml::file(file_path)), - "json" => self.join(Yaml::file(file_path)), - "toml" => self.join(Yaml::file(file_path)), - _ => panic!("Format not supported") + fn join_file(self, file_path: PathBuf) -> Figment { + match file_path + .extension() + .expect("Could not determine config file type") + .to_string_lossy() + .as_ref() + { + "yaml" | "yml" => self.join(Yaml::file(file_path)), + "json" => self.join(Yaml::file(file_path)), + "toml" => self.join(Yaml::file(file_path)), + _ => panic!("Format not supported"), + } } - } } From f5719bcf55c409750af70bcec75a6f7369633734 Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sat, 10 Apr 2021 16:52:25 -0700 Subject: [PATCH 10/13] Set tab spaces to 2 --- rustfmt.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index 8b2d06a..41d9b1a 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,6 +2,6 @@ edition = "2018" merge_derives = true reorder_imports = true reorder_modules = true -tab_spaces = 2 +tab_spaces = 4 use_field_init_shorthand = true use_try_shorthand = true From a07b46932d64ff4cea46f775b2a4ad69d33486d1 Mon Sep 17 00:00:00 2001 From: DanielJoyce Date: Sat, 10 Apr 2021 16:54:51 -0700 Subject: [PATCH 11/13] Clean up html in preparation for websocket support --- src/bin/websockets.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bin/websockets.html b/src/bin/websockets.html index ddb9d9d..a42282d 100644 --- a/src/bin/websockets.html +++ b/src/bin/websockets.html @@ -97,8 +97,7 @@