appease clippy

pull/33/head
chris west 2 years ago
parent 105b737d1d
commit 7522427d71

291
Cargo.lock generated

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -8,53 +10,44 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"libc", "libc",
"winapi 0.3.8", "winapi",
] ]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.7" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.3.2" version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "c2-chacha"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
dependencies = [
"ppv-lite86",
]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.48" version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "0.1.10" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.6.4" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -62,9 +55,9 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.6.2" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]] [[package]]
name = "cp437" name = "cp437"
@ -72,6 +65,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "891a48ae269a368d5e45e0b13ee401f90d3d400da92d881f7cb67bc9da711c14" checksum = "891a48ae269a368d5e45e0b13ee401f90d3d400da92d881f7cb67bc9da711c14"
[[package]]
name = "fastrand"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
dependencies = [
"instant",
]
[[package]] [[package]]
name = "foreign-types" name = "foreign-types"
version = "0.3.2" version = "0.3.2"
@ -88,23 +90,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]] [[package]]
name = "getrandom" name = "hermit-abi"
version = "0.1.13" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [ dependencies = [
"cfg-if",
"libc", "libc",
"wasi",
] ]
[[package]] [[package]]
name = "hermit-abi" name = "instant"
version = "0.1.6" version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [ dependencies = [
"libc", "cfg-if",
] ]
[[package]] [[package]]
@ -115,24 +115,24 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.66" version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.8" version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.3" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
@ -152,31 +152,49 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
[[package]]
name = "once_cell"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.26" version = "0.10.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
"foreign-types", "foreign-types",
"lazy_static",
"libc", "libc",
"once_cell",
"openssl-macros",
"openssl-sys", "openssl-sys",
] ]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "openssl-probe" name = "openssl-probe"
version = "0.1.2" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.53" version = "0.9.77"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@ -200,97 +218,72 @@ dependencies = [
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.17" version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
[[package]]
name = "ppv-lite86"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "rand"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"
dependencies = [
"getrandom",
"libc",
"rand_chacha",
"rand_core",
"rand_hc",
]
[[package]] [[package]]
name = "rand_chacha" name = "proc-macro2"
version = "0.2.1" version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [ dependencies = [
"c2-chacha", "unicode-ident",
"rand_core",
] ]
[[package]] [[package]]
name = "rand_core" name = "quote"
version = "0.5.1" version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
dependencies = [ dependencies = [
"getrandom", "proc-macro2",
] ]
[[package]] [[package]]
name = "rand_hc" name = "redox_syscall"
version = "0.2.0" version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [ dependencies = [
"rand_core", "bitflags",
] ]
[[package]]
name = "redox_syscall"
version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]] [[package]]
name = "redox_termios" name = "redox_termios"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
dependencies = [ dependencies = [
"redox_syscall", "redox_syscall",
] ]
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [ dependencies = [
"winapi 0.3.8", "winapi",
] ]
[[package]] [[package]]
name = "schannel" name = "schannel"
version = "0.1.16" version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"winapi 0.3.8", "windows-sys",
] ]
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "0.3.4" version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c"
dependencies = [ dependencies = [
"bitflags",
"core-foundation", "core-foundation",
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -299,44 +292,55 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "0.3.3" version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc",
] ]
[[package]] [[package]]
name = "socks" name = "socks"
version = "0.3.2" version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6a64cfa9346d26e836a49fcc1ddfcb4d3df666b6787b6864db61d4918e1cbc2" checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"libc", "libc",
"winapi 0.2.8", "winapi",
"ws2_32-sys", ]
[[package]]
name = "syn"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
] ]
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.1.0" version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"fastrand",
"libc", "libc",
"rand",
"redox_syscall", "redox_syscall",
"remove_dir_all", "remove_dir_all",
"winapi 0.3.8", "winapi",
] ]
[[package]] [[package]]
name = "termion" name = "termion"
version = "1.5.5" version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e"
dependencies = [ dependencies = [
"libc", "libc",
"numtoa", "numtoa",
@ -355,39 +359,27 @@ dependencies = [
] ]
[[package]] [[package]]
name = "vcpkg" name = "unicode-ident"
version = "0.2.8" version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]] [[package]]
name = "wasi" name = "vcpkg"
version = "0.7.0" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [ dependencies = [
"winapi-i686-pc-windows-gnu", "winapi-i686-pc-windows-gnu",
"winapi-x86_64-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]] [[package]]
name = "winapi-i686-pc-windows-gnu" name = "winapi-i686-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -401,11 +393,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "ws2_32-sys" name = "windows-sys"
version = "0.2.1" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [ dependencies = [
"winapi 0.2.8", "windows_aarch64_msvc",
"winapi-build", "windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_msvc",
] ]
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"

@ -117,7 +117,7 @@ pub fn load() -> Result<Config> {
/// Attempt to load a config from disk. /// Attempt to load a config from disk.
pub fn load_file(path: &str) -> Result<Config> { pub fn load_file(path: &str) -> Result<Config> {
let mut reader = OpenOptions::new().read(true).open(&path)?; let mut reader = OpenOptions::new().read(true).open(path)?;
let mut file = String::new(); let mut file = String::new();
reader.read_to_string(&mut file)?; reader.read_to_string(&mut file)?;
parse(&file) parse(&file)

@ -1,7 +1,7 @@
use std::{borrow::Cow, io::Result}; use std::{borrow::Cow, io::Result};
/// Encoding of Gopher response. Only UTF8 and CP437 are supported. /// Encoding of Gopher response. Only UTF8 and CP437 are supported.
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Encoding { pub enum Encoding {
/// Unicode /// Unicode
UTF8, UTF8,
@ -33,7 +33,7 @@ impl Encoding {
if matches!(self, Encoding::CP437) { if matches!(self, Encoding::CP437) {
let mut converted = String::with_capacity(response.len()); let mut converted = String::with_capacity(response.len());
for b in response { for b in response {
converted.push_str(cp437::convert_byte(&b)); converted.push_str(cp437::convert_byte(b));
} }
Cow::from(converted) Cow::from(converted)
} else { } else {

@ -107,7 +107,7 @@ pub fn response_to_string(res: &[u8]) -> String {
fn clean_response(res: &mut String) { fn clean_response(res: &mut String) {
res.retain(|c| match c { res.retain(|c| match c {
'\u{007F}' => false, '\u{007F}' => false,
_ if c >= '\u{0080}' && c <= '\u{009F}' => false, _ if ('\u{0080}'..='\u{009F}').contains(&c) => false,
_ => true, _ => true,
}) })
} }
@ -283,7 +283,7 @@ pub fn parse_url(url: &str) -> Url {
host = &url[..idx]; host = &url[..idx];
sel = &url[idx..]; sel = &url[idx..];
} else { } else {
host = &url; host = url;
} }
// ipv6 // ipv6

@ -2,7 +2,7 @@ use std::fmt;
/// Gopher types are defined according to RFC 1436. /// Gopher types are defined according to RFC 1436.
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Type { pub enum Type {
Text, // 0 | cyan Text, // 0 | cyan
Menu, // 1 | blue Menu, // 1 | blue

@ -124,7 +124,7 @@ impl<'line, 'txt> Line<'line, 'txt> {
impl<'line, 'txt: 'line> std::ops::Deref for Line<'line, 'txt> { impl<'line, 'txt: 'line> std::ops::Deref for Line<'line, 'txt> {
type Target = LineSpan; type Target = LineSpan;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
&self.span self.span
} }
} }
@ -394,7 +394,7 @@ impl Menu {
out.push_str(color!(WhiteBG)); out.push_str(color!(WhiteBG));
out.push_str(color!(Red)); out.push_str(color!(Red));
} else { } else {
out.push_str(&match line.typ { out.push_str(match line.typ {
Type::Text => color!(Cyan), Type::Text => color!(Cyan),
Type::Menu => color!(Blue), Type::Menu => color!(Blue),
Type::Info => color!(Yellow), Type::Info => color!(Yellow),
@ -895,7 +895,7 @@ impl Menu {
} }
} }
Key::Char(c) => { Key::Char(c) => {
if !c.is_digit(10) { if !c.is_ascii_digit() {
return Action::Keypress(key); return Action::Keypress(key);
} }
@ -936,7 +936,7 @@ pub fn parse(url: &str, raw: String) -> Menu {
break; break;
} }
if line == "" { if line.is_empty() {
start += 1; start += 1;
continue; continue;
} }

@ -42,7 +42,7 @@ pub fn append(filename: &str, label: &str, url: &str) -> Result<()> {
path().and_then(|dotdir| { path().and_then(|dotdir| {
let path = dotdir.join(filename); let path = dotdir.join(filename);
if let Ok(mut file) = OpenOptions::new().append(true).create(true).open(path) { if let Ok(mut file) = OpenOptions::new().append(true).create(true).open(path) {
let u = gopher::parse_url(&url); let u = gopher::parse_url(url);
write!( write!(
file, file,
"{}{}\t{}\t{}\t{}\r\n", "{}{}\t{}\t{}\t{}\r\n",
@ -69,7 +69,7 @@ pub fn prepend(filename: &str, label: &str, url: &str) -> Result<()> {
.create(true) .create(true)
.open(path) .open(path)
{ {
let url = gopher::parse_url(&url); let url = gopher::parse_url(url);
let mut buf = vec![]; let mut buf = vec![];
file.read_to_end(&mut buf)?; file.read_to_end(&mut buf)?;
file.seek(std::io::SeekFrom::Start(0))?; file.seek(std::io::SeekFrom::Start(0))?;

@ -273,7 +273,7 @@ impl UI {
} else { } else {
self.spinner("", move || gopher::fetch_url(&thread_url, tls, tor))?? self.spinner("", move || gopher::fetch_url(&thread_url, tls, tor))??
}; };
let typ = gopher::type_for_url(&url); let typ = gopher::type_for_url(url);
match typ { match typ {
Type::Menu | Type::Search => Ok(Box::new(Menu::from( Type::Menu | Type::Search => Ok(Box::new(Menu::from(
url, url,
@ -289,7 +289,7 @@ impl UI {
/// Get Menu for on-line help, home page, etc, ex: gopher://phetch/1/help/types /// Get Menu for on-line help, home page, etc, ex: gopher://phetch/1/help/types
fn load_internal(&mut self, url: &str) -> Result<Box<dyn View>> { fn load_internal(&mut self, url: &str) -> Result<Box<dyn View>> {
if let Some(source) = help::lookup( if let Some(source) = help::lookup(
&url.trim_start_matches("gopher://phetch/") url.trim_start_matches("gopher://phetch/")
.trim_start_matches("1/"), .trim_start_matches("1/"),
) { ) {
Ok(Box::new(Menu::from( Ok(Box::new(Menu::from(
@ -467,11 +467,7 @@ impl UI {
out.flush().expect(ERR_STDOUT); out.flush().expect(ERR_STDOUT);
if let Ok(key) = self.keys.lock().unwrap().recv() { if let Ok(key) = self.keys.lock().unwrap().recv() {
match key { matches!(key, Key::Char('\n') | Key::Char('y') | Key::Char('Y'))
Key::Char('\n') => true,
Key::Char('y') | Key::Char('Y') => true,
_ => false,
}
} else { } else {
false false
} }
@ -588,10 +584,8 @@ impl UI {
} }
thread::spawn(move || { thread::spawn(move || {
for event in stdin().keys() { for key in stdin().keys().flatten() {
if let Ok(key) = event { sender.send(key).unwrap();
sender.send(key).unwrap();
}
} }
}); });
@ -672,7 +666,7 @@ impl UI {
's' => { 's' => {
if let Some(view) = self.views.get(self.focused) { if let Some(view) = self.views.get(self.focused) {
let url = view.url(); let url = view.url();
match bookmarks::save(&url, &url) { match bookmarks::save(url, url) {
Ok(()) => { Ok(()) => {
let msg = format!("Saved bookmark: {}", url); let msg = format!("Saved bookmark: {}", url);
self.set_status(&msg); self.set_status(&msg);
@ -684,7 +678,7 @@ impl UI {
'u' => { 'u' => {
if let Some(view) = self.views.get(self.focused) { if let Some(view) = self.views.get(self.focused) {
let current_url = view.url(); let current_url = view.url();
if let Some(url) = self.prompt("Current URL: ", &current_url) { if let Some(url) = self.prompt("Current URL: ", current_url) {
self.open(&url, &url)?; self.open(&url, &url)?;
} }
} }
@ -692,7 +686,7 @@ impl UI {
'y' => { 'y' => {
if let Some(view) = self.views.get(self.focused) { if let Some(view) = self.views.get(self.focused) {
let url = view.url(); let url = view.url();
utils::copy_to_clipboard(&url)?; utils::copy_to_clipboard(url)?;
let msg = format!("Copied {} to clipboard.", url); let msg = format!("Copied {} to clipboard.", url);
self.set_status(&msg); self.set_status(&msg);
} }

@ -1,6 +1,6 @@
/// The mode our text UI is in. Run mode is the default while /// The mode our text UI is in. Run mode is the default while
/// Print doesn't show the cursor, among other things. /// Print doesn't show the cursor, among other things.
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Mode { pub enum Mode {
/// Default, interactive mode. /// Default, interactive mode.
/// phetch URL /// phetch URL

@ -36,7 +36,7 @@ macro_rules! error {
std::io::Error::new(std::io::ErrorKind::Other, $e) std::io::Error::new(std::io::ErrorKind::Other, $e)
}; };
($e:expr, $($y:expr),*) => { ($e:expr, $($y:expr),*) => {
error!(format!($e, $($y),*)); error!(format!($e, $($y),*))
}; };
} }

Loading…
Cancel
Save