diff --git a/Cargo.lock b/Cargo.lock index 9a3f2a5..ba5c229 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -43,63 +43,70 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -112,9 +119,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" @@ -124,21 +131,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecount" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" [[package]] name = "bytefmt" @@ -151,18 +158,15 @@ dependencies = [ [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" [[package]] name = "cfg-if" @@ -172,22 +176,22 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.32" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] name = "clap" -version = "4.4.18" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -195,9 +199,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -207,33 +211,33 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "confy" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d296c475c6ed4093824c28e222420831d27577aaaf0a1163a3b7fc35b248a5" +checksum = "45b1f4c00870f07dc34adcac82bb6a72cc5aabca8536ba1797e01df51d2ce9a0" dependencies = [ "directories", "serde", @@ -259,9 +263,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "darling" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ "darling_core", "darling_macro", @@ -269,27 +273,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] @@ -325,9 +329,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -340,9 +344,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -350,9 +354,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fnv" @@ -391,6 +395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -425,6 +430,7 @@ checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", + "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -434,9 +440,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -445,23 +451,23 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "h2" -version = "0.3.26" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", "http", - "indexmap 2.1.0", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -476,9 +482,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" @@ -487,10 +493,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "hermit-abi" -version = "0.3.4" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" @@ -500,9 +506,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "0.2.11" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -511,69 +517,111 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", "http", - "pin-project-lite", ] [[package]] -name = "httparse" -version = "1.8.0" +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] [[package]] -name = "httpdate" -version = "1.0.3" +name = "httparse" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "hyper" -version = "0.14.28" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", - "futures-core", "futures-util", "h2", "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", + "http-body-util", "hyper", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -621,12 +669,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -636,17 +684,23 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -665,46 +719,39 @@ dependencies = [ "tabled", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.152" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", - "redox_syscall", ] [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -714,9 +761,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ "mime", "unicase", @@ -724,9 +771,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -744,11 +791,10 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -761,29 +807,25 @@ dependencies = [ ] [[package]] -name = "num-traits" -version = "0.2.17" +name = "num-conv" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] -name = "num_cpus" -version = "1.16.0" +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "hermit-abi", - "libc", + "autocfg", ] [[package]] name = "object" -version = "0.32.2" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "memchr", ] @@ -796,11 +838,11 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -817,7 +859,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] @@ -828,18 +870,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.2.1+3.2.0" +version = "300.3.1+3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -871,11 +913,31 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[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.70", +] + [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -885,9 +947,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "powerfmt" @@ -921,36 +983,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -959,9 +1012,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -971,9 +1024,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -982,26 +1035,30 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2", "http", "http-body", + "http-body-util", "hyper", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -1011,9 +1068,11 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -1025,30 +1084,85 @@ dependencies = [ "winreg", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustls-webpki" +version = "0.102.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" @@ -1061,11 +1175,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -1074,9 +1188,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -1084,29 +1198,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", @@ -1115,9 +1229,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -1136,16 +1250,17 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.5.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c" +checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.1.0", + "indexmap 2.2.6", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -1153,14 +1268,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.5.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298" +checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] @@ -1172,21 +1287,39 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "socket2" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" @@ -1201,15 +1334,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -1248,7 +1387,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c138f99377e5d653a371cdad263615634cfc8467685dfe8e73e2b8e98f44b17" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", @@ -1257,45 +1396,45 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", ] [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -1310,18 +1449,19 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1334,15 +1474,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "pin-project-lite", "socket2", "windows-sys 0.48.0", @@ -1358,25 +1497,35 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.8.8" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", @@ -1386,26 +1535,47 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", "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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + [[package]] name = "tower-service" version = "0.3.2" @@ -1460,24 +1630,30 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -1486,9 +1662,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "vcpkg" @@ -1519,9 +1695,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1529,24 +1705,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -1556,9 +1732,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1566,28 +1742,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -1599,7 +1775,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -1617,7 +1793,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -1637,17 +1813,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1658,9 +1835,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1670,9 +1847,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1682,9 +1859,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1694,9 +1877,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1706,9 +1889,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -1718,9 +1901,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1730,25 +1913,31 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.34" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.50.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", ] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index 4c58b4f..52f2bc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,10 +15,10 @@ exclude = [".gitignore", ".github/*"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "4.4.18", features = ["derive"] } -confy = "0.6.0" -serde = { version = "1.0.195", features = ["derive"] } -reqwest = { version = "0.11.23", features = [ +clap = { version = "4.5.9", features = ["derive"] } +confy = "0.6.1" +serde = { version = "1.0.204", features = ["derive"] } +reqwest = { version = "0.12.5", features = [ "json", "blocking", "multipart", @@ -26,8 +26,8 @@ reqwest = { version = "0.11.23", features = [ ] } tabled = { version = "0.15.0", features = ["derive"] } bytefmt = "0.1.7" -serde_json = { version = "1.0.111", features = ["std"] } -serde_with = { version = "3.5.1", features = [] } +serde_json = { version = "1.0.120", features = ["std"] } +serde_with = { version = "3.8.3", features = [] } [[bin]] name = "kaput" diff --git a/src/main.rs b/src/main.rs index c92840d..10973d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -use clap::{arg, Arg, Command}; +use clap::{value_parser, Arg, Command}; +use reqwest::blocking::Client; use serde::{Deserialize, Serialize}; use std::path::PathBuf; use std::process::{Command as ProcessCommand, Stdio}; @@ -21,11 +22,11 @@ impl Default for ConfigFile { } /// Verifies that the user has a valid API key set and that their account is still active -fn require_auth(config: &ConfigFile) -> put::account::AccountResponse { +fn require_auth(client: &Client, config: &ConfigFile) -> put::account::AccountResponse { if config.api_token.is_empty() { panic!("missing API key, please login to your Put.io account using the `login` command") } - let account = put::account::info(config.api_token.clone()) + let account = put::account::info(client, &config.api_token) .expect("invalid OAuth token in config, login again using the `login` command"); if !account.info.account_active { panic!("inactive Put.io account") @@ -43,15 +44,15 @@ fn cli() -> Command { Command::new("login") .about("Login to your Put.io account") .long_about( - "Logs into your Put.io by saving an auth token locally on your device.", - ), + "Logs into your Put.io by saving an auth token locally on your device." + ) ) .subcommand( Command::new("logout") .about("Logout of your account") .long_about( - "Logs out of your Put.io account by removing the auth token saved on your device.", - ), + "Logs out of your Put.io account by removing the auth token saved on your device." + ) ) .subcommand( Command::new("files") @@ -62,46 +63,90 @@ fn cli() -> Command { Command::new("list") .about("List your files and folders") .long_about("Lists your files and folders.") - .arg(arg!([FOLDER_ID] "Lists the contents of a folder (optional)")) - .arg(Arg::new("self") + .arg( + Arg::new("FOLDER_ID") + .help("Lists the contents of a folder (optional)") + .value_parser(value_parser!(u32)) + .required(false) + .num_args(1) + ) + .arg( + Arg::new("self") .short('s') .long("self") .help("If set, returns the info for the folder itself in JSON format") .required(false) - .num_args(0)) - .arg(Arg::new("json") + .num_args(0) + ) + .arg( + Arg::new("json") .long("json") .help("If set, returns the output in JSON format") .required(false) - .num_args(0)), + .num_args(0) + ) ) .subcommand( Command::new("search") .about("Search you and your friend's files") .long_about("Searches you and your friend's files.") .arg_required_else_help(true) - .arg(arg!( "Keyword(s) to search for (required)")), + .arg( + Arg::new("QUERY") + .required(true) + .help("Keyword(s) to search for (required)") + ) ) .subcommand( Command::new("url") .about("Generate a URl for downloading a file or folder") .long_about("Generates a URl for downloading a file or folder.") .arg_required_else_help(true) - .arg(arg!( "ID of a file or folder (required)")), + .arg( + Arg::new("FILE_ID") + .value_parser(value_parser!(u32)) + .required(true) + .help("ID of a file or folder (required)") + ) ) .subcommand( Command::new("download") .about("Download a file or folder") .long_about("Downloads a file or folder from your account to your device.") .arg_required_else_help(true) - .arg(arg!( "ID of a file or folder (required)")), + .arg( + Arg::new("FILE_ID") + .value_parser(value_parser!(u32)) + .required(true) + .help("ID(s) of a file or folder (required)") + ) + .arg( + Arg::new("path") + .short('p') + .long("path") + .help("Path to download the file(s) to") + .required(false).num_args(1) + ) + .arg( + Arg::new("recursive") + .short('r') + .long("recursive") + .help("Download the contents of a folder recursively without creating a zip") + .required(false) + .num_args(0) + ) ) .subcommand( Command::new("delete") .about("Delete file(s)") .long_about("Deletes the specified file(s) on your account.") .arg_required_else_help(true) - .arg(arg!( "ID(s) of a file (required)")), + .arg( + Arg::new("FILE_ID") + .value_parser(value_parser!(u32)) + .required(true) + .help("ID(s) of a file (required)") + ) ) .subcommand( Command::new("upload") @@ -112,6 +157,7 @@ fn cli() -> Command { Arg::new("parent_id") .short('p') .long("parent") + .value_parser(value_parser!(u32)) .help("ID of a Put folder to upload to instead of the root folder") .required(false) ) @@ -131,37 +177,77 @@ fn cli() -> Command { .num_args(0) ) .arg( - arg!( ... "Valid paths of files to upload") - .value_parser(clap::value_parser!(PathBuf)), - ), + Arg::new("PATH") + .required(true) + .help("Valid paths of files to upload") + .value_parser(value_parser!(PathBuf)) + ) ) .subcommand( Command::new("move") .about("Move files") .long_about("Moves a file to a different parent folder.") .arg_required_else_help(true) - .arg(arg!( "ID(s) of the file(s) to move (required)")) - .arg(arg!( "ID of the new parent folder (required)")), + .arg( + Arg::new("FILE_ID") + .help("ID of the file to move (required)") + .value_parser(value_parser!(u32)) + .required(true)) + .arg( + Arg::new("PARENT_ID") + .help("ID of the new parent folder (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) ) .subcommand( Command::new("rename") .about("Rename files") .long_about("Renames a file.") .arg_required_else_help(true) - .arg(arg!( "ID of the file to rename (required)")) - .arg(arg!( "New name for the file (required)")), + .arg( + Arg::new("FILE_ID") + .help("ID of the file to rename (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) + .arg( + Arg::new("NAME") + .help("New name for the file (required)") + .required(true) + ) ) .subcommand( Command::new("extractions") .about("List active extractions") - .long_about("Lists active extractions."), + .long_about("Lists active extractions.") ) .subcommand( Command::new("extract") .about("Extract ZIP and RAR archives") .long_about("Extracts ZIP and RAR archives.") .arg_required_else_help(true) - .arg(arg!( "ID(s) of the file(s) to extract (required)")), + .arg( + Arg::new("FILE_ID") + .help("ID of the file to extract (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) + ) + .subcommand( + Command::new("play") + .about("Stream a video file") + .long_about( + "Plays a video file using MPV.\n\ + If you do not have MPV installed, visit https://mpv.io/installation/.", + ) + .arg_required_else_help(true) + .arg( + Arg::new("FILE_ID") + .help("ID of a video file (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) ) ) .subcommand( @@ -172,73 +258,82 @@ fn cli() -> Command { .subcommand( Command::new("list") .about("List the current transfers on your account") - .long_about("Lists the current transfers on your account."), + .long_about("Lists the current transfers on your account.") ) .subcommand( Command::new("add") .about("Add new transfer with URL") .long_about("Adds new transfers to your account with a URL.") .arg_required_else_help(true) - .arg(arg!( "URL to transfer (required)")) + .arg( + Arg::new("URL") + .help("URL to transfer (required)") + .required(true) + ) .arg( Arg::new("parent_id") - .short('p') - .long("parent") - .help("ID of a Put folder to upload to instead of the root folder") - .required(false) - ), + .short('p') + .long("parent") + .value_parser(value_parser!(u32)) + .help("ID of a Put folder to upload to instead of the root folder") + .required(false) + ) ) .subcommand( Command::new("cancel") .about("Cancel or remove transfers") .long_about("Cancels or removes transfers on your account. If transfer is in SEEDING state, stops seeding. Otherwise, it removes the transfer entry. Does not remove their files.") .arg_required_else_help(true) - .arg(arg!( "ID of a transfer (required)")), + .arg( + Arg::new("TRANSFER_ID") + .help("ID of a transfer (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) ) .subcommand( Command::new("retry") .about("Retry failed transfer") .long_about("Retries failed transfers.") .arg_required_else_help(true) - .arg(arg!( "ID of a transfer (required)")), + .arg( + Arg::new("TRANSFER_ID") + .help("ID of a transfer (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) ) .subcommand( Command::new("remove") .about("Remove transfer(s)") .long_about("Removes transfer(s).") .arg_required_else_help(true) - .arg(arg!( "ID(s) of a transfer (required)")), + .arg( + Arg::new("TRANSFER_ID") + .help("ID of a transfer (required)") + .value_parser(value_parser!(u32)) + .required(true) + ) ) .subcommand( Command::new("clean") .about("Clear all finished transfers") .long_about( - "Clears all finished transfers on your account. Does not remove files.", - ), - ) - , - ) - .subcommand( - Command::new("play") - .about("Stream a video file") - .long_about( - "Plays a video file using MPV.\n\ - If you do not have MPV installed, visit https://mpv.io/installation/.", + "Clears all finished transfers on your account. Does not remove files." + ) ) - .arg_required_else_help(true) - .arg(arg!( "ID of a file (required)")), ) .subcommand( Command::new("whoami") .about("Check what account you are logged into") .long_about( - "Returns the username and email of the currently authenticated Put.io user.", - ), + "Returns the username and email of the currently authenticated Put.io user." + ) ) .subcommand( Command::new("debug") .about("Check the current config") - .long_about("Returns the current config file and path."), + .long_about("Returns the current config file and path.") ) } @@ -248,12 +343,15 @@ const APP_NAME: &str = "kaput-cli"; fn main() { let config: ConfigFile = confy::load(APP_NAME, None).expect("reading config file"); - let matches = cli().get_matches(); + let matches: clap::ArgMatches = cli().get_matches(); + + let client: Client = reqwest::blocking::Client::new(); match matches.subcommand() { Some(("login", _sub_matches)) => { // Create new OOB code and prompt user to link - let oob_code = put::oob::get().expect("fetching OOB code"); + let oob_code = put::oob::get(&client).expect("fetching OOB code"); + println!( "Go to https://put.io/link and enter the code: {:#?}", oob_code @@ -270,7 +368,7 @@ fn main() { thread::sleep(three_seconds); - let get_oauth_token_result = put::oob::check(oob_code.clone()); + let get_oauth_token_result = put::oob::check(&client, &oob_code); let oauth_token = match get_oauth_token_result { Ok(token) => token, @@ -299,35 +397,9 @@ fn main() { confy::store(APP_NAME, None, cfg).expect("updating config file"); println!("Signed out successfully!") } - Some(("play", sub_matches)) => { - require_auth(&config); - - let file_id = sub_matches - .get_one::("FILE_ID") - .expect("missing file ID argument") - .parse::() - .expect("parsing file_id"); - - let file_info = - put::files::list(config.api_token.clone(), file_id).expect("fetching file info"); - - if file_info.parent.file_type != "VIDEO" { - println!("File type must be video."); - return; - } - - let download_url = put::files::url(config.api_token, file_id).expect("generating url"); - - ProcessCommand::new("mpv") - .arg(download_url.url) - .stdout(Stdio::piped()) - .spawn() - .expect("error while spawning mpv (is it installed?)") - .wait() - .expect("error while running MPV"); - } Some(("whoami", _sub_matches)) => { - let account = require_auth(&config); + let account: put::account::AccountResponse = require_auth(&client, &config); + println!( "Logged in as {} ({})", account.info.username, account.info.mail @@ -341,19 +413,45 @@ fn main() { println!("{:#?}", config); } Some(("files", sub_matches)) => match sub_matches.subcommand() { + Some(("play", sub_matches)) => { + require_auth(&client, &config); + + let file_id = sub_matches.get_one("FILE_ID").expect("missing file ID"); + + let file_info: put::files::FilesResponse = + put::files::list(&client, &config.api_token, *file_id) + .expect("fetching file info"); + + if file_info.parent.file_type != "VIDEO" { + println!("File type must be video."); + return; + } + + let download_url: put::files::UrlResponse = + put::files::url(&client, &config.api_token, *file_id).expect("generating url"); + + ProcessCommand::new("mpv") + .arg(download_url.url) + .stdout(Stdio::piped()) + .spawn() + .expect("error while spawning mpv (is it installed?)") + .wait() + .expect("error while running MPV"); + } Some(("list", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); - let folder_id_result = sub_matches.get_one::("FOLDER_ID"); + let folder_id_result = sub_matches.get_one("FOLDER_ID"); - let folder_id = match folder_id_result { - Some(folder_id) => folder_id.parse::().expect("parsing folder_id"), + let folder_id: u32 = match folder_id_result { + Some(folder_id) => *folder_id, None => 0, }; - let files = put::files::list(config.api_token, folder_id).expect("fetching files"); + let files = put::files::list(&client, &config.api_token, folder_id) + .expect("fetching files"); - let should_only_show_self = sub_matches.get_one::("self"); + let should_only_show_self: Option<&bool> = sub_matches.get_one::("self"); if *should_only_show_self.unwrap_or(&false) { // Only show info for the parent @@ -379,37 +477,38 @@ fn main() { println!("{}\n", table); } Some(("url", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); - let file_id = sub_matches - .get_one::("FILE_ID") - .expect("missing file ID argument") - .parse::() - .expect("parsing file_id"); + let file_id: &u32 = sub_matches + .get_one("FILE_ID") + .expect("missing file ID argument"); - let file_info = put::files::list(config.api_token.clone(), file_id) + let file_info = put::files::list(&client, &config.api_token, *file_id) .expect("fetching file info"); if file_info.parent.file_type == "FOLDER" { println!("Creating zip..."); - let zip_url = - put::zips::create(config.api_token, file_id).expect("generating zip url"); + + let zip_url = put::zips::create(&client, &config.api_token, *file_id) + .expect("generating zip url"); + println!("URL: {:#?}", zip_url); } else { - let download_url = - put::files::url(config.api_token, file_id).expect("generating url"); + let download_url = put::files::url(&client, &config.api_token, *file_id) + .expect("generating url"); + println!("URL: {:#?}", download_url.url) } } Some(("search", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let query = sub_matches .get_one::("QUERY") .expect("missing query argument"); - let files = put::files::search(config.api_token, query.to_string()) - .expect("querying files"); + let files = + put::files::search(&client, &config.api_token, query).expect("querying files"); let table = Table::new(files.files).with(Style::markdown()).to_string(); @@ -417,72 +516,32 @@ fn main() { println!("{}\n", table); } Some(("download", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); - let file_id = sub_matches - .get_one::("FILE_ID") - .expect("missing file_id argument"); - let file_id_int = file_id.parse::().expect("parsing file_id"); - let files = put::files::list(config.api_token.clone(), file_id_int) - .expect("querying files"); - if files.parent.file_type != "FOLDER" { - // ID is for a file - let url_response = put::files::url(config.api_token, file_id_int) - .expect("creating download URL"); + let recursive = sub_matches.get_flag("recursive"); - println!("Downloading: {}\n", files.parent.name); + let path = sub_matches.get_one::("path"); - // https://rust-lang-nursery.github.io/rust-cookbook/os/external.html#redirect-both-stdout-and-stderr-of-child-process-to-the-same-file - ProcessCommand::new("curl") - .arg("-C") - .arg("-") - .arg("-o") - .arg(files.parent.name) - .arg(url_response.url) - .stdout(Stdio::piped()) - .spawn() - .expect("error while spawning curl") - .wait_with_output() - .expect("running CURL command"); - - println!("\nDownload finished!") - } else { - // ID is for a folder - // Create a ZIP - println!("Creating ZIP..."); - let zip_url = put::zips::create(config.api_token, files.parent.id) - .expect("creating zip job"); - println!("ZIP created!"); - - println!("Downloading: {}\n", files.parent.name); - - // https://rust-lang-nursery.github.io/rust-cookbook/os/external.html#redirect-both-stdout-and-stderr-of-child-process-to-the-same-file - ProcessCommand::new("curl") - .arg("-C") - .arg("-") - .arg("-o") - .arg(files.parent.name + ".zip") - .arg(zip_url) - .stdout(Stdio::piped()) - .spawn() - .expect("failed to run CURL command") - .wait_with_output() - .expect("failed to run CURL command"); + let file_id = sub_matches + .get_one("FILE_ID") + .expect("missing file_id argument"); - println!("\nDownload finished!") - } + put::files::download(&client, &config.api_token, *file_id, recursive, path) + .expect("downloading file(s)"); } Some(("delete", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let file_id = sub_matches .get_one::("FILE_ID") .expect("missing file_id argument"); - put::files::delete(config.api_token, file_id.to_string()).expect("deleting file"); + + put::files::delete(&client, &config.api_token, file_id).expect("deleting file"); + println!("File deleted!"); } Some(("upload", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let parent_id = sub_matches.get_one::("parent_id"); @@ -528,43 +587,43 @@ fn main() { } } Some(("move", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let file_id = sub_matches - .get_one::("FILE_ID") + .get_one("FILE_ID") .expect("missing file_id argument"); + let new_parent_id = sub_matches - .get_one::("PARENT_ID") - .expect("missing parent_id argument") - .parse::() - .expect("parsing file_id"); + .get_one("PARENT_ID") + .expect("missing parent_id argument"); - put::files::mv(config.api_token, file_id.to_string(), new_parent_id) + put::files::mv(&client, &config.api_token, *file_id, *new_parent_id) .expect("moving file(s)"); + println!("File(s) moved!"); } Some(("rename", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let file_id = sub_matches - .get_one::("FILE_ID") - .expect("missing file_id argument") - .parse::() - .expect("parsing file_id"); + .get_one("FILE_ID") + .expect("missing file_id argument"); + let new_name = sub_matches - .get_one::("NAME") + .get_one("NAME") .expect("missing parent_id argument"); - put::files::rename(config.api_token, file_id, new_name.to_string()) + put::files::rename(&client, &config.api_token, *file_id, new_name) .expect("renaming file"); println!("File renamed!"); } Some(("extractions", _sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); + + let extractions = put::files::get_extractions(&client, &config.api_token) + .expect("fetching extractions"); - let extractions = - put::files::get_extractions(config.api_token).expect("fetching extractions"); let table = Table::new(extractions.extractions) .with(Style::markdown()) .to_string(); @@ -573,13 +632,13 @@ fn main() { println!("{}\n", table); } Some(("extract", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let file_id = sub_matches - .get_one::("FILE_ID") + .get_one("FILE_ID") .expect("missing file_id argument"); - put::files::extract(config.api_token, file_id.to_string()) + put::files::extract(&client, &config.api_token, *file_id) .expect("starting extraction"); println!("Extraction started!"); @@ -590,67 +649,71 @@ fn main() { }, Some(("transfers", sub_matches)) => match sub_matches.subcommand() { Some(("list", _sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let transfers_response = - put::transfers::list(config.api_token).expect("fetching transfers"); + put::transfers::list(&client, &config.api_token).expect("fetching transfers"); + let table = Table::new(transfers_response.transfers) .with(Style::markdown()) .to_string(); + println!("\n# Your transfers\n"); println!("{}\n", table); } Some(("add", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); - let url = sub_matches - .get_one::("URL") - .expect("missing URL argument"); + let url = sub_matches.get_one("URL").expect("missing URL argument"); - let parent = sub_matches.get_one::("parent_id"); + let parent = sub_matches.get_one("parent_id"); - put::transfers::add(config.api_token, url.to_string(), parent.cloned()) + put::transfers::add(&client, &config.api_token, url, parent) .expect("starting transfer"); println!("Transfer added!"); } Some(("cancel", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let transfer_id = sub_matches - .get_one::("TRANSFER_ID") + .get_one("TRANSFER_ID") .expect("missing transfer_id argument"); - put::transfers::cancel(config.api_token, transfer_id.to_string()) + + put::transfers::cancel(&client, &config.api_token, *transfer_id) .expect("cancelling transfer"); + println!("Transfer cancelled or removed!"); } Some(("retry", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let transfer_id = sub_matches - .get_one::("TRANSFER_ID") - .expect("missing transfer_id argument") - .parse::() - .expect("parsing file_id"); + .get_one("TRANSFER_ID") + .expect("missing transfer_id argument"); + + put::transfers::retry(&client, &config.api_token, *transfer_id) + .expect("retrying transfer"); - put::transfers::retry(config.api_token, transfer_id).expect("restarting transfer"); println!("Transfer restarted!"); } Some(("remove", sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); let transfer_id = sub_matches - .get_one::("TRANSFER_ID") + .get_one("TRANSFER_ID") .expect("missing transfer_id argument"); - put::transfers::remove(config.api_token, transfer_id.to_string()) + put::transfers::remove(&client, &config.api_token, *transfer_id) .expect("removing transfer"); + println!("Transfer removed!"); } Some(("clean", _sub_matches)) => { - require_auth(&config); + require_auth(&client, &config); + + put::transfers::clean(&client, &config.api_token).expect("clearing transfers"); - put::transfers::clean(config.api_token).expect("clearing transfers"); println!("Transfers cleaned!"); } _ => { diff --git a/src/put/account.rs b/src/put/account.rs index 28a2c3a..645df80 100644 --- a/src/put/account.rs +++ b/src/put/account.rs @@ -1,3 +1,4 @@ +use reqwest::{blocking::Client, Error}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] @@ -13,12 +14,12 @@ pub struct AccountResponse { } /// Returns the user's account info. -pub fn info(api_key: String) -> Result> { - let client = reqwest::blocking::Client::new(); +pub fn info(client: &Client, api_key: &String) -> Result { let response: AccountResponse = client .get("https://api.put.io/v2/account/info") - .header("authorization", format!("Bearer {}", api_key)) + .header("authorization", format!("Bearer {api_key}")) .send()? .json()?; + Ok(response) } diff --git a/src/put/files.rs b/src/put/files.rs index b4cc374..cb3321d 100644 --- a/src/put/files.rs +++ b/src/put/files.rs @@ -1,10 +1,15 @@ -use std::fmt; +use std::process::{Command as ProcessCommand, Stdio}; +use std::{fmt, fs}; -use reqwest::blocking::multipart; +use reqwest::blocking::multipart::Form; +use reqwest::blocking::Client; +use reqwest::Error; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DefaultOnNull}; use tabled::Tabled; +use crate::put; + #[derive(Debug, Serialize, Deserialize)] pub struct FileSize(u64); @@ -33,18 +38,15 @@ pub struct FilesResponse { } /// Returns the user's files. -pub fn list( - api_token: String, - parent_id: u32, -) -> Result> { - let client = reqwest::blocking::Client::new(); +pub fn list(client: &Client, api_token: &String, parent_id: u32) -> Result { let response: FilesResponse = client .get(format!( "https://api.put.io/v2/files/list?parent_id={parent_id}" )) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) } @@ -56,26 +58,27 @@ pub struct SearchResponse { /// Searches files for given keyword. pub fn search( - api_token: String, - query: String, -) -> Result> { - let client = reqwest::blocking::Client::new(); + client: &Client, + api_token: &String, + query: &String, +) -> Result { let response: SearchResponse = client .get(format!("https://api.put.io/v2/files/search?query={query}")) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) } /// Delete file(s) -pub fn delete(api_token: String, file_id: String) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("file_ids", file_id); +pub fn delete(client: &Client, api_token: &String, file_id: &str) -> Result<(), Error> { + let form: Form = Form::new().text("file_ids", file_id.to_owned()); + client .post("https://api.put.io/v2/files/delete") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) @@ -87,30 +90,31 @@ pub struct UrlResponse { } /// Returns a download URL for a given file. -pub fn url(api_token: String, file_id: u32) -> Result> { - let client = reqwest::blocking::Client::new(); +pub fn url(client: &Client, api_token: &String, file_id: u32) -> Result { let response: UrlResponse = client .get(format!("https://api.put.io/v2/files/{file_id}/url")) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) } /// Moves a file to a different parent pub fn mv( - api_token: String, - file_id: String, + client: &Client, + api_token: &String, + file_id: u32, new_parent_id: u32, -) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new() - .text("file_ids", file_id) +) -> Result<(), Error> { + let form: Form = Form::new() + .text("file_ids", file_id.to_string()) .text("parent_id", new_parent_id.to_string()); + client .post("https://api.put.io/v2/files/move") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) @@ -118,31 +122,32 @@ pub fn mv( /// Renames a file pub fn rename( - api_token: String, + client: &Client, + api_token: &String, file_id: u32, - new_name: String, -) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new() + new_name: &String, +) -> Result<(), Error> { + let form = Form::new() .text("file_id", file_id.to_string()) - .text("name", new_name); + .text("name", new_name.to_owned()); + client .post("https://api.put.io/v2/files/rename") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) } /// Extracts ZIP and RAR archives -pub fn extract(api_token: String, file_id: String) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("file_ids", file_id); +pub fn extract(client: &Client, api_token: &String, file_id: u32) -> Result<(), Error> { + let form: Form = Form::new().text("file_ids", file_id.to_string()); + client .post("https://api.put.io/v2/files/extract") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) @@ -150,7 +155,7 @@ pub fn extract(api_token: String, file_id: String) -> Result<(), Box Result> { - let client = reqwest::blocking::Client::new(); +pub fn get_extractions(client: &Client, api_token: &String) -> Result { let response: ExtractionResponse = client .get("https://api.put.io/v2/files/extract") - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) } + +// Downloads a file or folder +pub fn download( + client: &Client, + api_token: &String, + file_id: u32, + recursive: bool, + path: Option<&String>, +) -> Result<(), Error> { + let files: FilesResponse = + put::files::list(client, api_token, file_id).expect("querying files"); + + match files.parent.file_type.as_str() { + "FOLDER" => { + // ID is for a folder + match recursive { + true => { + // Recursively download the folder + let directory_path: String = match path { + Some(p) => format!("{}/{}", p, files.parent.name), // Use the provided path if there is one + None => format!("./{}", files.parent.name), + }; + + fs::create_dir_all(directory_path.clone()).expect("creating directory"); + + for file in files.files { + download(client, api_token, file.id, true, Some(&directory_path)) + .expect("downloading file recursively"); + } + } + false => { + // Create a ZIP + println!("Creating ZIP..."); + + let zip_url: String = put::zips::create(client, api_token, files.parent.id) + .expect("creating zip job"); + + println!("ZIP created!"); + + let output_path: String = match path { + Some(p) => format!("{}/{}.zip", p, files.parent.name), + None => format!("./{}.zip", files.parent.name), + }; + + println!("Downloading: {}", files.parent.name); + println!("Saving to: {}\n", output_path); + + // https://rust-lang-nursery.github.io/rust-cookbook/os/external.html#redirect-both-stdout-and-stderr-of-child-process-to-the-same-file + ProcessCommand::new("curl") + .arg("-C") + .arg("-") + .arg("-o") + .arg(output_path) + .arg(zip_url) + .stdout(Stdio::piped()) + .spawn() + .expect("failed to run CURL command") + .wait_with_output() + .expect("failed to run CURL command"); + + println!("\nDownload finished!\n") + } + } + } + _ => { + // ID is for a file + let url_response: UrlResponse = + put::files::url(client, api_token, file_id).expect("creating download URL"); + + let output_path: String = match path { + Some(p) => format!("{}/{}", p, files.parent.name), + None => format!("./{}", files.parent.name), + }; + + println!("Downloading: {}", files.parent.name); + println!("Saving to: {}\n", output_path); + + // https://rust-lang-nursery.github.io/rust-cookbook/os/external.html#redirect-both-stdout-and-stderr-of-child-process-to-the-same-file + ProcessCommand::new("curl") + .arg("-C") + .arg("-") + .arg("-o") + .arg(output_path) + .arg(url_response.url) + .stdout(Stdio::piped()) + .spawn() + .expect("error while spawning curl") + .wait_with_output() + .expect("running CURL command"); + + println!("\nDownload finished!\n") + } + } + + Ok(()) +} diff --git a/src/put/oob.rs b/src/put/oob.rs index 69dda15..6ca93af 100644 --- a/src/put/oob.rs +++ b/src/put/oob.rs @@ -1,20 +1,27 @@ use std::collections::HashMap; +use reqwest::{blocking::Client, Error}; + /// Returns a new OOB code. -pub fn get() -> Result> { - let resp = reqwest::blocking::get("https://api.put.io/v2/oauth2/oob/code?app_id=4701")? +pub fn get(client: &Client) -> Result { + let resp = client + .get("https://api.put.io/v2/oauth2/oob/code?app_id=4701") + .send()? .json::>()?; - let code = resp.get("code").expect("fetching OOB code"); - Ok(code.to_string()) + + let code: &String = resp.get("code").expect("fetching OOB code"); + + Ok(code.clone()) } /// Returns new OAuth token if the OOB code is linked to the user's account. -pub fn check(oob_code: String) -> Result> { - let resp = reqwest::blocking::get(format!( - "https://api.put.io/v2/oauth2/oob/code/{}", - oob_code - ))? - .json::>()?; - let token = resp.get("oauth_token").expect("deserializing OAuth token"); - Ok(token.to_string()) +pub fn check(client: &Client, oob_code: &String) -> Result { + let resp = client + .get(format!("https://api.put.io/v2/oauth2/oob/code/{oob_code}")) + .send()? + .json::>()?; + + let token: &String = resp.get("oauth_token").expect("fetching OAuth token"); + + Ok(token.clone()) } diff --git a/src/put/transfers.rs b/src/put/transfers.rs index 33ae49e..6ea8f3b 100644 --- a/src/put/transfers.rs +++ b/src/put/transfers.rs @@ -1,4 +1,7 @@ -use reqwest::blocking::multipart; +use reqwest::{ + blocking::{multipart::Form, Client}, + Error, +}; use serde::{Deserialize, Deserializer, Serialize}; use tabled::Tabled; @@ -32,80 +35,85 @@ pub struct ListTransferResponse { } /// Returns the user's transfers. -pub fn list(api_token: String) -> Result> { - let client = reqwest::blocking::Client::new(); +pub fn list(client: &Client, api_token: &String) -> Result { let response: ListTransferResponse = client .get("https://api.put.io/v2/transfers/list") - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) } /// Starts a new transfer on the account with the given URL. pub fn add( - api_token: String, - url: String, - parent_id: Option, -) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new() - .text("url", url) - .text("save_parent_id", parent_id.unwrap_or(String::from("0"))); + client: &Client, + api_token: &String, + url: &String, + parent_id: Option<&u32>, +) -> Result<(), Error> { + let parent_id: u32 = match parent_id { + Some(id) => *id, + None => 0, + }; + + let form: Form = Form::new() + .text("url", url.to_owned()) + .text("save_parent_id", parent_id.to_string()); client .post("https://api.put.io/v2/transfers/add") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) } /// Cancels or removes transfers -pub fn cancel(api_token: String, transfer_id: String) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("transfer_ids", transfer_id); +pub fn cancel(client: &Client, api_token: &String, transfer_id: u32) -> Result<(), Error> { + let form: Form = Form::new().text("transfer_ids", transfer_id.to_string()); + client .post("https://api.put.io/v2/transfers/cancel") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) } /// Clears all finished transfers -pub fn clean(api_token: String) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); +pub fn clean(client: &Client, api_token: &String) -> Result<(), Error> { client .post("https://api.put.io/v2/transfers/clean") - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; + Ok(()) } /// Retries failed transfers -pub fn retry(api_token: String, transfer_id: u32) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("id", transfer_id.to_string()); +pub fn retry(client: &Client, api_token: &String, transfer_id: u32) -> Result<(), Error> { + let form: Form = Form::new().text("id", transfer_id.to_string()); + client .post("https://api.put.io/v2/transfers/retry") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) } /// Removes transfers by ID -pub fn remove(api_token: String, transfer_id: String) -> Result<(), Box> { - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("transfer_ids", transfer_id); +pub fn remove(client: &Client, api_token: &String, transfer_id: u32) -> Result<(), Error> { + let form: Form = Form::new().text("transfer_ids", transfer_id.to_string()); + client .post("https://api.put.io/v2/transfers/remove") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()?; Ok(()) diff --git a/src/put/zips.rs b/src/put/zips.rs index f1c1c27..96f920f 100644 --- a/src/put/zips.rs +++ b/src/put/zips.rs @@ -1,6 +1,9 @@ use std::{thread, time}; -use reqwest::blocking::multipart; +use reqwest::{ + blocking::{multipart::Form, Client}, + Error, +}; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] @@ -11,21 +14,21 @@ pub struct CreateZipResponse { /// Creates a new ZIP job with the given file id. /// /// Waits for the zip job complete, and returns a string with the download URL. -pub fn create(api_token: String, file_id: u32) -> Result> { +pub fn create(client: &Client, api_token: &String, file_id: u32) -> Result { // Start ZIP job - let client = reqwest::blocking::Client::new(); - let form = multipart::Form::new().text("file_ids", format!("{file_id}")); + let form: Form = Form::new().text("file_ids", file_id.to_string()); + let response: CreateZipResponse = client .post("https://api.put.io/v2/zips/create") .multipart(form) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; // Wait for ZIP job to finish loop { let check_zip_response = - get(api_token.clone(), response.zip_id).expect("checking zip status"); + get(client, api_token, response.zip_id).expect("checking zip status"); if let Some(zip_url) = check_zip_response.url { return Ok(zip_url); @@ -42,13 +45,12 @@ pub struct CheckZipResponse { } /// Checks the status of a given zip job -pub fn get(api_token: String, zip_id: u32) -> Result> { - let client = reqwest::blocking::Client::new(); - +pub fn get(client: &Client, api_token: &String, zip_id: u32) -> Result { let response: CheckZipResponse = client .get(format!("https://api.put.io/v2/zips/{zip_id}")) - .header("authorization", format!("Bearer {}", api_token)) + .header("authorization", format!("Bearer {api_token}")) .send()? .json()?; + Ok(response) }