From e27b47c66b86292564b1c4f08c959ed4977f2196 Mon Sep 17 00:00:00 2001 From: toast Date: Tue, 8 Oct 2024 17:25:07 +1100 Subject: [PATCH] Apply Clippy suggestions --- Cargo.lock | 289 ++++++++++++--------------- Cargo.toml | 14 +- build.rs | 2 +- src/commands/midi.rs | 4 +- src/commands/status.rs | 2 +- src/commands/uptime.rs | 24 +-- src/internals/config.rs | 2 +- src/internals/tasks.rs | 4 +- src/internals/tasks/rss.rs | 2 +- src/internals/tasks/rss/esxi.rs | 10 +- src/internals/tasks/rss/github.rs | 31 ++- src/internals/tasks/rss/gportal.rs | 33 ++- src/internals/tasks/rss/processor.rs | 12 +- src/internals/tasks/rss/rust.rs | 10 +- src/internals/utils.rs | 2 +- src/main.rs | 17 +- 16 files changed, 203 insertions(+), 255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cd3752..d76e1c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -58,13 +58,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -75,9 +75,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "cargo_toml" -version = "0.20.4" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad639525b1c67b6a298f378417b060fbc04618bea559482a8484381cce27d965" +checksum = "88da5a13c620b4ca0078845707ea9c3faf11edbc3ffd8497d11d686211cd1ac0" dependencies = [ "serde", "toml", @@ -229,9 +229,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.21" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "shlex", ] @@ -368,7 +368,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -379,7 +379,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -389,7 +389,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -458,7 +458,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -500,9 +500,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "feed-rs" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c546f6f85e02eaca09e6a6dd22fe4db839745f55ae16c8f36626980a57f5bc4" +checksum = "6511d29ecf291f32688d546c33d8e62bbebd4fe60ef40b52b20e3f3a0ec6eb56" dependencies = [ "chrono", "mediatype", @@ -517,9 +517,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -557,9 +557,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -581,44 +581,44 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -664,9 +664,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "glob" @@ -718,6 +718,12 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.5.0" @@ -808,9 +814,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -886,7 +892,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.13", + "rustls 0.23.14", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -911,9 +917,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -924,7 +930,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -980,12 +985,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -1002,9 +1007,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "itoa" @@ -1023,7 +1028,7 @@ dependencies = [ [[package]] name = "kon" -version = "0.3.20" +version = "0.4.0" dependencies = [ "bb8", "bb8-postgres", @@ -1033,7 +1038,7 @@ dependencies = [ "once_cell", "poise", "regex", - "reqwest 0.12.7", + "reqwest 0.12.8", "serde", "serde_json", "sysinfo", @@ -1045,9 +1050,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "linked-hash-map" @@ -1228,18 +1233,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "openssl" @@ -1264,7 +1269,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1342,26 +1347,6 @@ dependencies = [ "siphasher 0.3.11", ] -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1376,9 +1361,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "poise" @@ -1406,7 +1391,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1455,9 +1440,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -1550,9 +1535,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e86f5670bd8b028edfb240f0616cad620705b31ec389d55e4f3da2c38dcd48" +checksum = "92f61607c4c4442b575fbc3f31a5dd4e5dd69cfea8f6afec5b83e24f61c126ab" dependencies = [ "arc-swap", "async-trait", @@ -1571,18 +1556,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -1592,9 +1577,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -1603,9 +1588,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -1653,9 +1638,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", @@ -1678,7 +1663,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 2.1.3", + "rustls-pemfile 2.2.0", "serde", "serde_json", "serde_urlencoded", @@ -1766,9 +1751,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "once_cell", "rustls-pki-types", @@ -1788,19 +1773,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-webpki" @@ -1840,9 +1824,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -1931,7 +1915,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1948,9 +1932,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -2131,9 +2115,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -2157,9 +2141,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.31.4" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" +checksum = "e3b5ae3f4f7d64646c46c4cae4e3f01d1c5d255c7406fdd7c7f999a94e488791" dependencies = [ "core-foundation-sys", "libc", @@ -2219,9 +2203,9 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -2232,22 +2216,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2302,7 +2286,7 @@ version = "0.4.0" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" checksum = "69fb4574f5ff7b98c91c98d3a8be2eb4c55a895c44f0682aa269c67b5922bbf8" dependencies = [ - "reqwest 0.12.7", + "reqwest 0.12.8", "serde", "serde_json", "tokio", @@ -2335,7 +2319,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2401,7 +2385,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.13", + "rustls 0.23.14", "rustls-pki-types", "tokio", ] @@ -2458,9 +2442,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -2469,27 +2453,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -2516,7 +2479,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2530,9 +2493,9 @@ dependencies = [ [[package]] name = "triomphe" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" [[package]] name = "trust-dns-proto" @@ -2627,7 +2590,7 @@ checksum = "5dece5c06268af6a9ff4541788601e560a4284ffebfb357f713d676f13b964db" dependencies = [ "chrono", "dashmap", - "hashbrown", + "hashbrown 0.14.5", "mini-moka", "parking_lot", "secrecy", @@ -2645,7 +2608,7 @@ checksum = "905e88c2a4cc27686bd57e495121d451f027e441388a67f773be729ad4be1ea8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2659,9 +2622,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -2680,9 +2643,9 @@ dependencies = [ [[package]] name = "unicode-properties" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] name = "untrusted" @@ -2793,7 +2756,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -2827,7 +2790,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2840,9 +2803,9 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" dependencies = [ "futures-util", "js-sys", @@ -2963,7 +2926,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2974,7 +2937,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3166,9 +3129,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -3201,7 +3164,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index dab705d..4376f1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,21 @@ [package] name = "kon" -version = "0.3.20" +version = "0.4.0" edition = "2021" [dependencies] bb8 = "0.8.5" bb8-postgres = "0.8.1" bb8-redis = "0.17.0" -cargo_toml = "0.20.4" -feed-rs = "2.1.0" -once_cell = "1.19.0" +cargo_toml = "0.20.5" +feed-rs = "2.1.1" +once_cell = "1.20.2" poise = "0.6.1" -regex = "1.10.6" -reqwest = { version = "0.12.7", features = ["json", "native-tls-vendored"] } +regex = "1.11.0" +reqwest = { version = "0.12.8", features = ["json", "native-tls-vendored"] } serde = "1.0.210" serde_json = "1.0.128" -sysinfo = "0.31.4" +sysinfo = "0.32.0" tokenservice-client = { version = "0.4.0", registry = "gitea" } tokio = { version = "1.40.0", features = ["macros", "signal", "rt-multi-thread"] } tokio-postgres = "0.7.12" diff --git a/build.rs b/build.rs index e59543a..79b060c 100644 --- a/build.rs +++ b/build.rs @@ -11,7 +11,7 @@ fn main() { { let git_branch = std::process::Command::new("git") - .args(&["rev-parse", "--abbrev-ref", "HEAD"]) + .args(["rev-parse", "--abbrev-ref", "HEAD"]) .output() .expect("Command execution failed"); diff --git a/src/commands/midi.rs b/src/commands/midi.rs index 57f7766..69c2a2e 100644 --- a/src/commands/midi.rs +++ b/src/commands/midi.rs @@ -53,13 +53,13 @@ pub async fn midi_to_wav( let midi_path = &message.attachments[0].filename; write(midi_path, bytes)?; - let wav_path = re.replace(&midi_path, ".wav"); + let wav_path = re.replace(midi_path, ".wav"); let sf2_path = "/tmp/FluidR3_GM.sf2"; write(sf2_path, include_bytes!("../internals/assets/FluidR3_GM.sf2"))?; let output = std::process::Command::new("fluidsynth") - .args(&["-ni", sf2_path, midi_path, "-F", &wav_path]) + .args(["-ni", sf2_path, midi_path, "-F", &wav_path]) .output(); // Just to add an info to console to tell what the bot is doing when MIDI file is downloaded. diff --git a/src/commands/status.rs b/src/commands/status.rs index 206de6a..58304b3 100644 --- a/src/commands/status.rs +++ b/src/commands/status.rs @@ -54,7 +54,7 @@ fn process_pms_statuses(servers: Vec<(String, Vec)>) -> Vec<(String, Stri _ => "Unknown" }; let name = id_name_map.get(id).unwrap_or(&name); - server_map.entry(title.clone()).or_insert_with(Vec::new).push((name.to_owned().to_string(), status.to_owned())); + server_map.entry(title.clone()).or_default().push((name.to_owned().to_string(), status.to_owned())); } } diff --git a/src/commands/uptime.rs b/src/commands/uptime.rs index f041ec7..593d8a7 100644 --- a/src/commands/uptime.rs +++ b/src/commands/uptime.rs @@ -29,19 +29,17 @@ fn get_os_info() -> String { let mut name = "BoringOS".to_string(); let mut version = "v0.0".to_string(); - if let Ok(file) = File::open(&path) { + if let Ok(file) = File::open(path) { let reader = BufReader::new(file); - for line in reader.lines() { - if let Ok(line) = line { - if line.starts_with("NAME=") { - name = line.split('=').nth(1).unwrap_or_default().trim_matches('"').to_string(); - } else if line.starts_with("VERSION=") { - version = line.split('=').nth(1).unwrap_or_default().trim_matches('"').to_string(); - } else if line.starts_with("VERSION_ID=") { - version = line.split('=').nth(1).unwrap_or_default().trim_matches('"').to_string(); - } + let set_value = |s: String| s.split('=').nth(1).unwrap_or_default().trim_matches('"').to_string(); + reader.lines().map_while(Result::ok).for_each(|line| { + match line { + l if l.starts_with("NAME=") => name = set_value(l), + l if l.starts_with("VERSION=") => version = set_value(l), + l if l.starts_with("VERSION_ID=") => version = set_value(l), + _ => {} } - } + }); } format!("{} {}", name, version) @@ -69,11 +67,11 @@ pub async fn uptime(ctx: poise::Context<'_, (), Error>) -> Result<(), Error> { proc_uptime = now.duration_since(time_started).unwrap().as_secs(); } - let stat_msg = vec![ + let stat_msg = [ format!("**{} {}** `{}:{}`", _bot.name, BOT_VERSION.as_str(), GIT_COMMIT_HASH, GIT_COMMIT_BRANCH), format!(">>> System: `{}`", format_duration(sys_uptime)), format!("Process: `{}`", format_duration(proc_uptime)), - format!("CPU: `{}`", format!("{}", cpu[0].brand())), + format!("CPU: `{}`", cpu[0].brand()), format!("OS: `{}`", get_os_info()) ]; ctx.reply(stat_msg.join("\n")).await?; diff --git a/src/internals/config.rs b/src/internals/config.rs index 4f58297..e7638a4 100644 --- a/src/internals/config.rs +++ b/src/internals/config.rs @@ -9,7 +9,7 @@ pub struct ConfigMeta { } #[cfg(feature = "production")] -pub static BINARY_PROPERTIES: LazyLock = LazyLock::new(|| ConfigMeta::new()); +pub static BINARY_PROPERTIES: LazyLock = LazyLock::new(ConfigMeta::new); #[cfg(not(feature = "production"))] pub static BINARY_PROPERTIES: LazyLock = LazyLock::new(|| diff --git a/src/internals/tasks.rs b/src/internals/tasks.rs index e08e933..da9784f 100644 --- a/src/internals/tasks.rs +++ b/src/internals/tasks.rs @@ -16,11 +16,11 @@ use std::{ }; fn task_info(name: &str, message: &str) { - println!("{}", format!("TaskScheduler[{}]: {}", name, message)) + println!("TaskScheduler[{}]: {}", name, message) } fn task_err(name: &str, message: &str) { - eprintln!("{}", format!("TaskScheduler[{}:Error]: {}", name, message)) + eprintln!("TaskScheduler[{}:Error]: {}", name, message) } static TASK_RUNNING: AtomicBool = AtomicBool::new(false); diff --git a/src/internals/tasks/rss.rs b/src/internals/tasks/rss.rs index 1a66636..c335aca 100644 --- a/src/internals/tasks/rss.rs +++ b/src/internals/tasks/rss.rs @@ -147,7 +147,7 @@ pub async fn rss(ctx: Arc) -> Result<(), Error> { #[cfg(not(feature = "production"))] let mut interval = interval(Duration::from_secs(30)); // Check feeds every 30 secs let mut first_run = true; - task_info(&TASK_NAME, "Task loaded!"); + task_info(TASK_NAME, "Task loaded!"); loop { interval.tick().await; diff --git a/src/internals/tasks/rss/esxi.rs b/src/internals/tasks/rss/esxi.rs index 0a6b33d..82b682e 100644 --- a/src/internals/tasks/rss/esxi.rs +++ b/src/internals/tasks/rss/esxi.rs @@ -42,11 +42,11 @@ pub async fn esxi_embed() -> Result, Error> { } } - let cached_patch = redis.get(&rkey).await.unwrap().unwrap_or_default(); + let cached_patch = redis.get(rkey).await.unwrap().unwrap_or_default(); if cached_patch.is_empty() { - redis.set(&rkey, &article.categories[3].term).await.unwrap(); - if let Err(y) = redis.expire(&rkey, REDIS_EXPIRY_SECS).await { + redis.set(rkey, &article.categories[3].term).await.unwrap(); + if let Err(y) = redis.expire(rkey, REDIS_EXPIRY_SECS).await { task_err("RSS", format!("[RedisExpiry]: {}", y).as_str()); } return Ok(None); @@ -54,9 +54,9 @@ pub async fn esxi_embed() -> Result, Error> { if let Some(patch) = get_patch_version(&article.categories[3].term) { if patch == cached_patch { - return Ok(None); + Ok(None) } else { - save_to_redis(&rkey, &article.categories[3].term).await?; + save_to_redis(rkey, &article.categories[3].term).await?; Ok(Some(CreateEmbed::new() .color(0x4EFBCB) .author(CreateEmbedAuthor::new(feed.title.unwrap().content).url(home_page)) diff --git a/src/internals/tasks/rss/github.rs b/src/internals/tasks/rss/github.rs index ad5d166..74ee804 100644 --- a/src/internals/tasks/rss/github.rs +++ b/src/internals/tasks/rss/github.rs @@ -36,17 +36,12 @@ pub async fn github_embed() -> Result, Error> { fn get_incident_id(input: &str) -> Option { let re = Regex::new(r#"/incidents/([a-zA-Z0-9]+)$"#).unwrap(); - if let Some(caps) = re.captures(input) { - Some(caps[1].to_string()) - } else { - None - } + re.captures(input).map(|caps| caps[1].to_string()) } - let cached_incident = redis.get(&rkey).await.unwrap().unwrap_or_default(); + let cached_incident = redis.get(rkey).await.unwrap().unwrap_or_default(); let new_content = format_html_to_discord(article.content.unwrap().body.unwrap()); - let color: u32; let update_patt = Regex::new(r"(?i)\bupdate\b").unwrap(); let investigating_patt = Regex::new(r"(?i)\binvestigating\b").unwrap(); let resolved_patt = Regex::new(r"(?i)\bresolved\b").unwrap(); @@ -54,20 +49,20 @@ pub async fn github_embed() -> Result, Error> { let first_entry = date_patt.split(&new_content).map(str::trim).find(|e| !e.is_empty()).unwrap_or(&new_content); - color = if update_patt.is_match(&first_entry) { + let color: u32 = if update_patt.is_match(first_entry) { IncidentColorMap::Update.color() - } else if investigating_patt.is_match(&first_entry) { + } else if investigating_patt.is_match(first_entry) { IncidentColorMap::Investigating.color() - } else if resolved_patt.is_match(&first_entry) { + } else if resolved_patt.is_match(first_entry) { IncidentColorMap::Resolved.color() } else { IncidentColorMap::Default.color() }; if cached_incident.is_empty() { - redis.set(&rkey, &get_incident_id(&article.links[0].href).unwrap()).await.unwrap(); + redis.set(rkey, &get_incident_id(&article.links[0].href).unwrap()).await.unwrap(); redis.set(&rkey_content, &new_content).await.unwrap(); - if let Err(y) = redis.expire(&rkey, REDIS_EXPIRY_SECS).await { + if let Err(y) = redis.expire(rkey, REDIS_EXPIRY_SECS).await { task_err("RSS", format!("[RedisExpiry]: {}", y).as_str()); } return Ok(None); @@ -77,28 +72,28 @@ pub async fn github_embed() -> Result, Error> { if incident == cached_incident { let cached_content: String = redis.get(&rkey_content).await.unwrap().unwrap_or_default(); if cached_content == new_content { - return Ok(None); + Ok(None) } else { redis.set(&rkey_content, &new_content).await.unwrap(); redis.expire(&rkey_content, 21600).await.unwrap(); - return Ok(Some(embed( + Ok(Some(embed( color, article.title.unwrap().content, incident_page, trim_old_content(&new_content), Timestamp::from(article.updated.unwrap()) - ))); + ))) } } else { - save_to_redis(&rkey, &incident).await?; + save_to_redis(rkey, &incident).await?; redis.set(&rkey_content, &new_content).await.unwrap(); - return Ok(Some(embed( + Ok(Some(embed( color, article.title.unwrap().content, incident_page, trim_old_content(&new_content), Timestamp::from(article.updated.unwrap()) - ))); + ))) } } else { task_err("RSS:GitHub", &format!("Incident ID does not match the expected RegEx pattern! ({})", &article.links[0].href)); diff --git a/src/internals/tasks/rss/gportal.rs b/src/internals/tasks/rss/gportal.rs index e5b2fe0..f3aa6d1 100644 --- a/src/internals/tasks/rss/gportal.rs +++ b/src/internals/tasks/rss/gportal.rs @@ -36,17 +36,12 @@ pub async fn gportal_embed() -> Result, Error> { fn get_incident_id(input: &str) -> Option { let re = Regex::new(r#"/incidents/([a-zA-Z0-9]+)$"#).unwrap(); - if let Some(caps) = re.captures(input) { - Some(caps[1].to_string()) - } else { - None - } + re.captures(input).map(|caps| caps[1].to_string()) } - let cached_incident = redis.get(&rkey).await.unwrap().unwrap_or_default(); + let cached_incident = redis.get(rkey).await.unwrap().unwrap_or_default(); let new_content = format_html_to_discord(article.content.unwrap().body.unwrap()); - let color: u32; let update_patt = Regex::new(r"(?i)\bupdate\b").unwrap(); let investigating_patt = Regex::new(r"(?i)\binvestigating\b").unwrap(); let monitoring_patt = Regex::new(r"(?i)\bmonitoring\b").unwrap(); @@ -55,22 +50,22 @@ pub async fn gportal_embed() -> Result, Error> { let first_entry = date_patt.split(&new_content).map(str::trim).find(|e| !e.is_empty()).unwrap_or(&new_content); - color = if update_patt.is_match(&first_entry) { + let color: u32 = if update_patt.is_match(first_entry) { IncidentColorMap::Update.color() - } else if investigating_patt.is_match(&first_entry) { + } else if investigating_patt.is_match(first_entry) { IncidentColorMap::Investigating.color() - } else if monitoring_patt.is_match(&first_entry) { + } else if monitoring_patt.is_match(first_entry) { IncidentColorMap::Monitoring.color() - } else if resolved_patt.is_match(&first_entry) { + } else if resolved_patt.is_match(first_entry) { IncidentColorMap::Resolved.color() } else { IncidentColorMap::Default.color() }; if cached_incident.is_empty() { - redis.set(&rkey, &get_incident_id(&article.links[0].href).unwrap()).await.unwrap(); + redis.set(rkey, &get_incident_id(&article.links[0].href).unwrap()).await.unwrap(); redis.set(&rkey_content, &new_content).await.unwrap(); - if let Err(y) = redis.expire(&rkey, REDIS_EXPIRY_SECS).await { + if let Err(y) = redis.expire(rkey, REDIS_EXPIRY_SECS).await { task_err("RSS", format!("[RedisExpiry]: {}", y).as_str()); } return Ok(None); @@ -80,28 +75,28 @@ pub async fn gportal_embed() -> Result, Error> { if incident == cached_incident { let cached_content: String = redis.get(&rkey_content).await.unwrap().unwrap_or_default(); if cached_content == new_content { - return Ok(None); + Ok(None) } else { redis.set(&rkey_content, &new_content).await.unwrap(); redis.expire(&rkey_content, 21600).await.unwrap(); - return Ok(Some(embed( + Ok(Some(embed( color, article.title.unwrap().content, incident_page, trim_old_content(&new_content), Timestamp::from(article.updated.unwrap()) - ))); + ))) } } else { - save_to_redis(&rkey, &incident).await?; + save_to_redis(rkey, &incident).await?; redis.set(&rkey_content, &new_content).await.unwrap(); - return Ok(Some(embed( + Ok(Some(embed( color, article.title.unwrap().content, incident_page, trim_old_content(&new_content), Timestamp::from(article.updated.unwrap()) - ))); + ))) } } else { task_err("RSS:GPortal", &format!("Incident ID does not match the expected RegEx pattern! ({})", &article.links[0].href)); diff --git a/src/internals/tasks/rss/processor.rs b/src/internals/tasks/rss/processor.rs index 2a536bf..cea9b76 100644 --- a/src/internals/tasks/rss/processor.rs +++ b/src/internals/tasks/rss/processor.rs @@ -80,25 +80,25 @@ pub async fn feed_processor(ctx: &Context) { Ok(None) => (), Err(y) => { log_msgs.push(format!("**[{TASK_NAME}:ESXi:Error]:** Feed failed with the following error:```\n{}\n```", y)); - task_err(&TASK_NAME, &y.to_string()) + task_err(TASK_NAME, &y.to_string()) } } match gportal_embed().await { - Ok(Some(embed)) => process_embed(&ctx, Some(embed), "RSS_GPortal_MsgID", "RSS_GPortal_Content").await.unwrap(), + Ok(Some(embed)) => process_embed(ctx, Some(embed), "RSS_GPortal_MsgID", "RSS_GPortal_Content").await.unwrap(), Ok(None) => (), Err(y) => { log_msgs.push(format!("**[{TASK_NAME}:GPortal:Error]:** Feed failed with the following error:```\n{}\n```", y)); - task_err(&TASK_NAME, &y.to_string()) + task_err(TASK_NAME, &y.to_string()) } } match github_embed().await { - Ok(Some(embed)) => process_embed(&ctx, Some(embed), "RSS_GitHub_MsgID", "RSS_GitHub_Content").await.unwrap(), + Ok(Some(embed)) => process_embed(ctx, Some(embed), "RSS_GitHub_MsgID", "RSS_GitHub_Content").await.unwrap(), Ok(None) => (), Err(y) => { log_msgs.push(format!("**[{TASK_NAME}:GitHub:Error]:** Feed failed with the following error:```\n{}\n```", y)); - task_err(&TASK_NAME, &y.to_string()) + task_err(TASK_NAME, &y.to_string()) } } @@ -109,7 +109,7 @@ pub async fn feed_processor(ctx: &Context) { Ok(None) => (), Err(y) => { log_msgs.push(format!("**[{TASK_NAME}:RustBlog:Error]:** Feed failed with the following error:```\n{}\n```", y)); - task_err(&TASK_NAME, &y.to_string()) + task_err(TASK_NAME, &y.to_string()) } } diff --git a/src/internals/tasks/rss/rust.rs b/src/internals/tasks/rss/rust.rs index 5461e6a..1dc75ab 100644 --- a/src/internals/tasks/rss/rust.rs +++ b/src/internals/tasks/rss/rust.rs @@ -29,11 +29,11 @@ pub async fn rust_message() -> Result, Error> { re.captures(input.as_str()).and_then(|caps| caps.get(1).map(|m| m.as_str().to_string())) } - let cached_blog = redis.get(&rkey).await.unwrap().unwrap_or_default(); + let cached_blog = redis.get(rkey).await.unwrap().unwrap_or_default(); if cached_blog.is_empty() { - redis.set(&rkey, get_blog_title(article.id).unwrap().as_str()).await.unwrap(); - if let Err(y) = redis.expire(&rkey, REDIS_EXPIRY_SECS).await { + redis.set(rkey, get_blog_title(article.id).unwrap().as_str()).await.unwrap(); + if let Err(y) = redis.expire(rkey, REDIS_EXPIRY_SECS).await { task_err("RSS", format!("[RedisExpiry]: {}", y).as_str()); } return Ok(None); @@ -41,9 +41,9 @@ pub async fn rust_message() -> Result, Error> { if let Some(blog) = get_blog_title(article.id) { if blog == cached_blog { - return Ok(None); + Ok(None) } else { - save_to_redis(&rkey, &blog).await?; + save_to_redis(rkey, &blog).await?; Ok(Some(format!("Rust Team has put out a new article!\n**[{}](<{}>)**", article.links[0].title.clone().unwrap(), article.links[0].href))) } } else { diff --git a/src/internals/utils.rs b/src/internals/utils.rs index 6367354..08059e7 100644 --- a/src/internals/utils.rs +++ b/src/internals/utils.rs @@ -5,7 +5,7 @@ use tokenservice_client::TokenServiceApi; use super::tsclient::TSClient; pub static BOT_VERSION: LazyLock = LazyLock::new(|| { - let cargo_version = cargo_toml::Manifest::from_str(&include_str!("../../Cargo.toml")) + let cargo_version = cargo_toml::Manifest::from_str(include_str!("../../Cargo.toml")) .unwrap() .package .unwrap() diff --git a/src/main.rs b/src/main.rs index 7e9eeaf..8acddcf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ async fn on_ready( println!("Event[Ready][Notice]: Session limit: {}/{}", session.remaining, session.total); } - println!("Event[Ready]: Build version: {} ({}:{})", BOT_VERSION.to_string(), GIT_COMMIT_HASH, GIT_COMMIT_BRANCH); + println!("Event[Ready]: Build version: {} ({}:{})", *BOT_VERSION, GIT_COMMIT_HASH, GIT_COMMIT_BRANCH); println!("Event[Ready]: Connected to API as {}", ready.user.name); let message = CreateMessage::new(); @@ -76,16 +76,13 @@ async fn event_processor( event: &FullEvent, _framework: poise::FrameworkContext<'_, (), Error> ) -> Result<(), Error> { - match event { - FullEvent::Ready { .. } => { - let thread_id = format!("{:?}", current().id()); - let thread_num: String = thread_id.chars().filter(|c| c.is_digit(10)).collect(); - println!("Event[Ready]: Task Scheduler operating on thread {}", thread_num); + if let FullEvent::Ready { .. } = event { + let thread_id = format!("{:?}", current().id()); + let thread_num: String = thread_id.chars().filter(|c| c.is_ascii_digit()).collect(); + println!("Event[Ready]: Task Scheduler operating on thread {}", thread_num); - let ctx = Arc::new(ctx.clone()); - run_task(ctx.clone(), rss).await; - } - _ => {} + let ctx = Arc::new(ctx.clone()); + run_task(ctx.clone(), rss).await; } Ok(())