From 4eb8208dc7057f9312016d351ff0389943c8eb5b Mon Sep 17 00:00:00 2001 From: TOwInOK <60252419+TOwInOK@users.noreply.github.com> Date: Mon, 27 May 2024 16:16:53 +0700 Subject: [PATCH] Changed PbMessages to Dictionary Split Dictionary into parts Now Version for Core in config works the same way as for Plugins Removed the lasy static, now one load at the beginning Changed language.toml to dictionary.toml Made Core removal more concise --- .gitignore | 2 +- Cargo.lock | 1889 -------------------- Cargo.toml | 3 +- dictionary.toml | 32 + dictionary_ru-example.toml | 32 + language.toml | 22 - language_ru-example.toml | 22 - settings.toml | 2 +- src/dictionary/config.rs | 36 + src/dictionary/defunct.rs | 28 + src/dictionary/dictionary.rs | 71 + src/dictionary/downloader.rs | 61 + src/dictionary/manager.rs | 37 + src/dictionary/mod.rs | 7 +- src/dictionary/model.rs | 31 + src/dictionary/pb_messages.rs | 71 - src/errors/error.rs | 12 +- src/lock/core.rs | 27 +- src/lock/ext_metalist.rs | 33 + src/lock/mod.rs | 57 +- src/main.rs | 7 +- src/{mananger => manager}/download.rs | 6 +- src/{mananger => manager}/manage.rs | 32 +- src/{mananger => manager}/messages.rs | 0 src/{mananger => manager}/mod.rs | 27 +- src/{mananger => manager}/watch_changer.rs | 21 +- src/models/cores/paper.rs | 25 +- src/models/cores/purpur.rs | 10 +- src/models/cores/vanilla.rs | 12 +- src/models/extensions/modrinth.rs | 10 +- src/settings/additions.rs | 16 +- src/settings/core.rs | 56 +- src/settings/extensions/plugin.rs | 10 +- src/settings/extensions/plugins.rs | 27 +- src/tr/download.rs | 16 +- src/tr/model/extension.rs | 2 +- 36 files changed, 520 insertions(+), 2232 deletions(-) delete mode 100644 Cargo.lock create mode 100644 dictionary.toml create mode 100644 dictionary_ru-example.toml delete mode 100644 language.toml delete mode 100644 language_ru-example.toml create mode 100644 src/dictionary/config.rs create mode 100644 src/dictionary/defunct.rs create mode 100644 src/dictionary/dictionary.rs create mode 100644 src/dictionary/downloader.rs create mode 100644 src/dictionary/manager.rs create mode 100644 src/dictionary/model.rs delete mode 100644 src/dictionary/pb_messages.rs create mode 100644 src/lock/ext_metalist.rs rename src/{mananger => manager}/download.rs (95%) rename src/{mananger => manager}/manage.rs (60%) rename src/{mananger => manager}/messages.rs (100%) rename src/{mananger => manager}/mod.rs (79%) rename src/{mananger => manager}/watch_changer.rs (78%) diff --git a/.gitignore b/.gitignore index 8b66dfd..e3db21d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,6 @@ vanilla.jar purpur.jar folia.jar waterfall.jar -Cargo.lock +./Cargo.lock src/.DS_Store ./.DS_Store \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 44f244d..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,1889 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "async-trait" -version = "0.1.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-watcher" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cb0d902fdf0ed6b7b4c199a4cd1fedfb095004a47aeb0fc7580372b373e1fb" -dependencies = [ - "async-trait", - "notify", - "serde", - "thiserror", - "tokio", - "tracing", -] - -[[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.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "backtrace" -version = "0.3.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cc" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "console" -version = "0.15.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "unicode-width", - "windows-sys 0.52.0", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" -dependencies = [ - "libc", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" - -[[package]] -name = "filetime" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "h2" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -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.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "indicatif" -version = "0.17.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" -dependencies = [ - "console", - "instant", - "number_prefix", - "portable-atomic", - "tokio", - "unicode-width", -] - -[[package]] -name = "indicatif-log-bridge" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2963046f28a204e3e3fd7e754fd90a6235da05b5378f24707ff0ec9513725ce3" -dependencies = [ - "indicatif", - "log", -] - -[[package]] -name = "inotify" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "is-terminal" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "kqueue" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" -dependencies = [ - "bitflags 1.3.2", - "libc", -] - -[[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.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "minecraft_addon_controller" -version = "0.1.0" -dependencies = [ - "async-trait", - "async-watcher", - "bytes", - "console", - "futures-util", - "indicatif", - "indicatif-log-bridge", - "lazy_static", - "log", - "md-5", - "pretty_env_logger", - "reqwest", - "serde", - "serde_json", - "sha1", - "sha2", - "thiserror", - "tokio", - "tokio-util", - "toml", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "notify" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" -dependencies = [ - "bitflags 1.3.2", - "crossbeam-channel", - "filetime", - "fsevent-sys", - "inotify", - "kqueue", - "libc", - "mio", - "walkdir", - "windows-sys 0.45.0", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.5.1", - "smallvec", - "windows-targets 0.52.5", -] - -[[package]] -name = "percent-encoding" -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", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - -[[package]] -name = "portable-atomic" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" - -[[package]] -name = "pretty_env_logger" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" -dependencies = [ - "env_logger", - "log", -] - -[[package]] -name = "proc-macro2" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -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_syscall" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" -dependencies = [ - "bitflags 2.5.0", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[package]] -name = "reqwest" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-tls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tokio-util", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "winreg", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[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 = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "security-framework" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" -dependencies = [ - "bitflags 2.5.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "serde" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_spanned" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -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.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "syn" -version = "2.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml" -version = "0.8.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" -dependencies = [ - "indexmap", - "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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" - -[[package]] -name = "url" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "wasm-streams" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi-util" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.5", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" - -[[package]] -name = "winnow" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] diff --git a/Cargo.toml b/Cargo.toml index 1f80ac0..a5e4f9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "minecraft_addon_controller" +name = "minecraft_dependency_manager" version = "0.1.0" edition = "2021" @@ -15,6 +15,7 @@ indicatif-log-bridge = "0.2.2" lazy_static = "1.4.0" log = "0.4.21" md-5 = "0.10.6" +once_cell = "1.19.0" pretty_env_logger = "0.5.0" reqwest = { version = "0.12.4", features = ["json", "stream"] } serde = { version = "1.0.199", features = ["derive"] } diff --git a/dictionary.toml b/dictionary.toml new file mode 100644 index 0000000..c182133 --- /dev/null +++ b/dictionary.toml @@ -0,0 +1,32 @@ +intro = "MDM готов к работе!" + +[downloader] +calculate_hash = "Вычислить хэш..." +delete_exist_version = "Удалить существующую версию!" +doest_need_to_update = "Не нужно обновлять!" +download_file = "Загрузить файл..." +file_downloaded = "Файл загружен!" +saving_file = "Сохранить файл..." +write_to_lock = "Запись в замок!" +done = "Выполнено!" + +[manager] +waiting_new_iteration = "Ожидание новой итерации..." +start_new_iteration = "Начать новую итерацию!" +stop_iteration = "Остановить итерацию!" +restart = "Перезапуск..." + +[config] +find_changes_in_settings = "Найти изменения в настройках!" +settings_changed = "Настройки изменены" +settings_rewritten = "Настройки переписаны" +settings_same = "Настройки прежние" + +[model] +init_work = "Генерировать ссылку..." +finding_version = "Поиск версии..." +make_link = "Создание ссылки..." + +[defunct] +start_remove_defunct = "Начать удаление дефункции" +remove_defunct = "Удалить пропущенное" diff --git a/dictionary_ru-example.toml b/dictionary_ru-example.toml new file mode 100644 index 0000000..3609868 --- /dev/null +++ b/dictionary_ru-example.toml @@ -0,0 +1,32 @@ +intro = "MDM готов к работе!" + +[downloader] +calculate_hash = "Вычислить хэш..." +delete_exist_version = "Удалить существующую версию!" +doest_need_to_update = "Не нужно обновлять!" +download_file = "Загрузить файл..." +file_downloaded = "Файл загружен!" +saving_file = "Сохранить файл..." +write_to_lock = "Запись в Lock файл!" +done = "Выполнено!" + +[manager] +waiting_new_iteration = "Ожидание новой итерации..." +start_new_iteration = "Начать новую итерацию!" +stop_iteration = "Остановить итерацию!" +restart = "Перезапуск..." + +[config] +find_changes_in_settings = "Найти изменения в настройках!" +settings_changed = "Настройки изменены" +settings_rewritten = "Настройки переписаны" +settings_same = "Настройки прежние" + +[model] +init_work = "Генерировать ссылку..." +finding_version = "Поиск версии..." +make_link = "Создание ссылки..." + +[defunct] +start_remove_defunct = "Начать удаление дефункции" +remove_defunct = "Удалить пропущенное" diff --git a/language.toml b/language.toml deleted file mode 100644 index 614c3e0..0000000 --- a/language.toml +++ /dev/null @@ -1,22 +0,0 @@ -calculate_hash = "Calculate hash..." -delete_exist_version = "Delete exist version!" -doest_need_to_update = "Does't need to update!" -done = "Done!" -download_file = "Download file..." -file_downloaded = "File downloaded!" -restart = "Restart..." -saving_file = "Saving file..." -start_new_iteration = "Start new iteration!" -stop_iteration = "Stop iteration!" -waiting_new_iteration = "Waiting new iteration..." -write_to_lock = "Write to lock!" -find_changes_in_settings = "Find some changes in settings!" -settings_changed = "Settings changed" -settings_has_rewrited = "Settings has rewrited" -settings_same = "Settings same" -intro = "MAC ready to work!" -init_work = "Generating link..." -finding_version = "Finding version..." -make_link = "Make link..." -start_remove_nonexist = "Start remove nonexist" -remove_nonexist = "Remove nonexist" diff --git a/language_ru-example.toml b/language_ru-example.toml deleted file mode 100644 index d05af7b..0000000 --- a/language_ru-example.toml +++ /dev/null @@ -1,22 +0,0 @@ -calculate_hash = "Вычисление хеша..." -delete_exist_version = "Удаление существующей версии!" -doest_need_to_update = "Не требует обновления!" -done = "Готово!" -download_file = "Загрузка файла..." -file_downloaded = "Файл загружен!" -restart = "Перезапуск..." -saving_file = "Сохранение файла..." -start_new_iteration = "Начало новой итерации!" -stop_iteration = "Остановка итерации!" -waiting_new_iteration = "Ожидание новой итерации..." -write_to_lock = "Логирование файла!" -find_changes_in_settings = "Найдены изменения в настройках!" -settings_changed = "Настройки изменены" -settings_has_rewrited = "Настройки перезаписаны" -settings_same = "Настройки те же" -intro = "МАК готов к работе!" -init_work = "Генерация ссылки..." -finding_version = "Поиск версии..." -make_link = "Создание ссылки..." -start_remove_nonexist = "Удаление не логируемых файлов" -remove_nonexist = "Удаление не существующего:" diff --git a/settings.toml b/settings.toml index 4dbd0da..595b544 100644 --- a/settings.toml +++ b/settings.toml @@ -1,6 +1,6 @@ [core] provider = "paper" -version = "1.20.4" +version = "1.20.6" [plugins] [plugins.simple-voice-chat] diff --git a/src/dictionary/config.rs b/src/dictionary/config.rs new file mode 100644 index 0000000..8630323 --- /dev/null +++ b/src/dictionary/config.rs @@ -0,0 +1,36 @@ +use serde::{Deserialize, Serialize}; +#[derive(Deserialize, Serialize)] +pub struct ConfigMessages { + find_changes_in_settings: String, + settings_changed: String, + settings_rewritten: String, + settings_same: String, +} + +impl ConfigMessages { + pub fn find_changes_in_settings(&self) -> &str { + &self.find_changes_in_settings + } + + pub fn settings_changed(&self) -> &str { + &self.settings_changed + } + + pub fn settings_rewritten(&self) -> &str { + &self.settings_rewritten + } + + pub fn settings_same(&self) -> &str { + &self.settings_same + } +} +impl Default for ConfigMessages { + fn default() -> Self { + Self { + find_changes_in_settings: "Find some changes in settings!".into(), + settings_changed: "Settings changed".into(), + settings_rewritten: "Settings rewritten".into(), + settings_same: "Settings same".into(), + } + } +} diff --git a/src/dictionary/defunct.rs b/src/dictionary/defunct.rs new file mode 100644 index 0000000..c912e0d --- /dev/null +++ b/src/dictionary/defunct.rs @@ -0,0 +1,28 @@ +use serde::{Deserialize, Serialize}; +#[derive(Deserialize, Serialize)] +pub struct DefunctMessages { + start_remove_defunct: String, + remove_defunct: String, +} + +impl DefunctMessages { + pub fn start_remove_defunct(&self) -> &str { + &self.start_remove_defunct + } + + pub fn remove_defunct(&self) -> &str { + &self.remove_defunct + } + pub fn remove_if_defunct(&self, name: &str) -> String { + format!("{}: {}", self.remove_defunct(), name) + } +} + +impl Default for DefunctMessages { + fn default() -> Self { + Self { + start_remove_defunct: "Start remove defunct".into(), + remove_defunct: "Remove defunct".into(), + } + } +} diff --git a/src/dictionary/dictionary.rs b/src/dictionary/dictionary.rs new file mode 100644 index 0000000..993dc27 --- /dev/null +++ b/src/dictionary/dictionary.rs @@ -0,0 +1,71 @@ +use log::{error, warn}; +use serde::{Deserialize, Serialize}; + +use crate::tr::load::Load; + +use super::{ + config::ConfigMessages, defunct::DefunctMessages, downloader::DownloaderMessages, + manager::ManagerMessages, model::ModelMessages, +}; + +#[derive(Deserialize, Serialize)] +pub struct MessageDictionary { + intro: String, + downloader: DownloaderMessages, + manager: ManagerMessages, + config: ConfigMessages, + model: ModelMessages, + defunct: DefunctMessages, +} + +impl Default for MessageDictionary { + fn default() -> Self { + Self { + intro: "MDM ready to work!".into(), + downloader: DownloaderMessages::default(), + manager: ManagerMessages::default(), + config: ConfigMessages::default(), + model: ModelMessages::default(), + defunct: DefunctMessages::default(), + } + } +} +impl MessageDictionary { + pub fn get_dict() -> Self { + match MessageDictionary::load_sync() { + Ok(e) => e, + Err(e) => { + error!("MessageDictionary: {}", e); + warn!("Load default Dictionary"); + MessageDictionary::default() + } + } + } + + pub fn intro(&self) -> &str { + &self.intro + } + + pub fn downloader(&self) -> &DownloaderMessages { + &self.downloader + } + + pub fn config(&self) -> &ConfigMessages { + &self.config + } + pub fn manager(&self) -> &ManagerMessages { + &self.manager + } + + pub fn model(&self) -> &ModelMessages { + &self.model + } + + pub fn defunct(&self) -> &DefunctMessages { + &self.defunct + } +} + +impl Load for MessageDictionary { + const PATH: &'static str = "dictionary.toml"; +} diff --git a/src/dictionary/downloader.rs b/src/dictionary/downloader.rs new file mode 100644 index 0000000..068bcd0 --- /dev/null +++ b/src/dictionary/downloader.rs @@ -0,0 +1,61 @@ +use serde::{Deserialize, Serialize}; +#[derive(Deserialize, Serialize)] +pub struct DownloaderMessages { + calculate_hash: String, + delete_exist_version: String, + doest_need_to_update: String, + download_file: String, + file_downloaded: String, + saving_file: String, + write_to_lock: String, + done: String, +} + +impl DownloaderMessages { + pub fn calculate_hash(&self) -> &str { + &self.calculate_hash + } + + pub fn delete_exist_version(&self) -> &str { + &self.delete_exist_version + } + + pub fn doest_need_to_update(&self) -> &str { + &self.doest_need_to_update + } + + pub fn download_file(&self) -> &str { + &self.download_file + } + + pub fn file_downloaded(&self) -> &str { + &self.file_downloaded + } + + pub fn saving_file(&self) -> &str { + &self.saving_file + } + + pub fn write_to_lock(&self) -> &str { + &self.write_to_lock + } + + pub fn done(&self) -> &str { + &self.done + } +} + +impl Default for DownloaderMessages { + fn default() -> Self { + Self { + calculate_hash: "Calculate hash...".into(), + delete_exist_version: "Delete exist version!".into(), + doest_need_to_update: "Does't need to update!".into(), + download_file: "Download file...".into(), + file_downloaded: "File downloaded!".into(), + saving_file: "Saving file...".into(), + write_to_lock: "Write to lock!".into(), + done: "Done!".into(), + } + } +} diff --git a/src/dictionary/manager.rs b/src/dictionary/manager.rs new file mode 100644 index 0000000..35ee71d --- /dev/null +++ b/src/dictionary/manager.rs @@ -0,0 +1,37 @@ +use serde::{Deserialize, Serialize}; +#[derive(Deserialize, Serialize)] +pub struct ManagerMessages { + waiting_new_iteration: String, + start_new_iteration: String, + stop_iteration: String, + restart: String, +} + +impl ManagerMessages { + pub fn waiting_new_iteration(&self) -> &str { + &self.waiting_new_iteration + } + + pub fn start_new_iteration(&self) -> &str { + &self.start_new_iteration + } + + pub fn stop_iteration(&self) -> &str { + &self.stop_iteration + } + + pub fn restart(&self) -> &str { + &self.restart + } +} + +impl Default for ManagerMessages { + fn default() -> Self { + Self { + waiting_new_iteration: "Waiting new iteration...".into(), + start_new_iteration: "Start new iteration!".into(), + stop_iteration: "Stop iteration!".into(), + restart: "Restarting...".into(), + } + } +} diff --git a/src/dictionary/mod.rs b/src/dictionary/mod.rs index a178bd8..59f84a1 100644 --- a/src/dictionary/mod.rs +++ b/src/dictionary/mod.rs @@ -1 +1,6 @@ -pub mod pb_messages; +mod config; +mod defunct; +pub mod dictionary; +mod downloader; +mod manager; +mod model; diff --git a/src/dictionary/model.rs b/src/dictionary/model.rs new file mode 100644 index 0000000..1df0520 --- /dev/null +++ b/src/dictionary/model.rs @@ -0,0 +1,31 @@ +use serde::{Deserialize, Serialize}; +#[derive(Deserialize, Serialize)] +pub struct ModelMessages { + init_work: String, + finding_version: String, + make_link: String, +} + +impl ModelMessages { + pub fn init_work(&self) -> &str { + &self.init_work + } + + pub fn finding_version(&self) -> &str { + &self.finding_version + } + + pub fn make_link(&self) -> &str { + &self.make_link + } +} + +impl Default for ModelMessages { + fn default() -> Self { + Self { + init_work: "Generating link...".into(), + finding_version: "Finding version...".into(), + make_link: "Making link...".into(), + } + } +} diff --git a/src/dictionary/pb_messages.rs b/src/dictionary/pb_messages.rs deleted file mode 100644 index 3d714f3..0000000 --- a/src/dictionary/pb_messages.rs +++ /dev/null @@ -1,71 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::tr::load::Load; - -#[derive(Deserialize, Serialize)] -pub struct PbMessages { - pub calculate_hash: String, - pub delete_exist_version: String, - pub doest_need_to_update: String, - pub done: String, - pub download_file: String, - pub file_downloaded: String, - pub restart: String, - pub saving_file: String, - pub start_new_iteration: String, - pub stop_iteration: String, - pub waiting_new_iteration: String, - pub write_to_lock: String, - // Config - pub find_changes_in_settings: String, - pub settings_changed: String, - pub settings_has_rewrited: String, - pub settings_same: String, - // Intro - pub intro: String, - // Models messages - pub init_work: String, - pub finding_version: String, - pub make_link: String, - // Remove nonexist - pub start_remove_nonexist: String, - pub remove_nonexist: String, -} - -impl Default for PbMessages { - fn default() -> Self { - Self { - restart: "Restart...".into(), - stop_iteration: "Stop iteration!".into(), - start_new_iteration: "Start new iteration!".into(), - waiting_new_iteration: "Waiting new iteration...".into(), - doest_need_to_update: "Does't need to update!".into(), - delete_exist_version: "Delete exist version!".into(), - download_file: "Download file...".into(), - saving_file: "Saving file...".into(), - write_to_lock: "Write to lock!".into(), - done: "Done!".into(), - file_downloaded: "File downloaded!".into(), - calculate_hash: "Calculate hash...".into(), - find_changes_in_settings: "Find some changes in settings!".into(), - settings_changed: "Settings changed".into(), - settings_has_rewrited: "Settings has rewrited".into(), - settings_same: "Settings same".into(), - intro: "MAC ready to work!".into(), - init_work: "Generating link...".into(), - finding_version: "Finding version...".into(), - make_link: "Make link...".into(), - start_remove_nonexist: "Start remove nonexist".into(), - remove_nonexist: "Remove nonexist".into(), - } - } -} -impl PbMessages { - pub fn remove_if_nonexist(&self, name: &str) -> String { - format!("{}: {}", self.remove_nonexist, name) - } -} - -impl Load for PbMessages { - const PATH: &'static str = "language.toml"; -} diff --git a/src/errors/error.rs b/src/errors/error.rs index 65922b8..71c387e 100644 --- a/src/errors/error.rs +++ b/src/errors/error.rs @@ -1,6 +1,6 @@ use thiserror::Error; -use crate::mananger::messages::Messages; +use crate::manager::messages::Messages; #[derive(Error, Debug)] pub enum CompareHashError { @@ -50,10 +50,11 @@ impl From for Error { let third_part: String = parts[3] .trim() .chars() - .filter(|x| *x != '^' || *x != '\\') + .filter(|x| *x != '^') + .filter(|x| *x != '\\') .collect(); format!( - " Where => {} ||| What => {} ||| why => {} ", + "Where => {} ||| What => {} ||| why => {}", parts[0].trim(), parts[2].trim(), third_part @@ -96,7 +97,10 @@ macro_rules! not_found_build_error { #[macro_export] macro_rules! not_found_version_error { ($arg:tt) => { - Err(Error::NotFound(format!("No one version ->{}<- find", $arg))) + Err(Error::NotFound(format!( + "No one version ->{:#?}<- find", + $arg + ))) }; } diff --git a/src/lock/core.rs b/src/lock/core.rs index 01c9201..6e418ef 100644 --- a/src/lock/core.rs +++ b/src/lock/core.rs @@ -1,21 +1,26 @@ use serde::{Deserialize, Serialize}; -use crate::settings::core::Provider; +use crate::{settings::core::Provider, tr::delete::Delete}; #[derive(Deserialize, Serialize, Debug, Default, PartialEq, Clone)] pub struct CoreMeta { - // Ядро + // Name of Core provider: Provider, - // Версия ядра - version: String, - // Версия билда ядра + // Version of core + version: Option, + // Build version of Core build: Option, - // Путь до ядра + // Path to core path: String, } impl CoreMeta { - pub fn new(provider: Provider, version: String, build: Option, path: String) -> Self { + pub fn new( + provider: Provider, + version: Option, + build: Option, + path: String, + ) -> Self { Self { provider, version, @@ -28,8 +33,8 @@ impl CoreMeta { &self.provider } - pub fn version(&self) -> &str { - &self.version + pub fn version(&self) -> Option<&String> { + self.version.as_ref() } pub fn build(&self) -> Option<&String> { @@ -38,4 +43,8 @@ impl CoreMeta { pub fn path(&self) -> &str { self.path.as_ref() } + pub async fn remove(&mut self) { + self.delete(&self.path).await; + } } +impl Delete for CoreMeta {} diff --git a/src/lock/ext_metalist.rs b/src/lock/ext_metalist.rs new file mode 100644 index 0000000..ddcce8d --- /dev/null +++ b/src/lock/ext_metalist.rs @@ -0,0 +1,33 @@ +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +use crate::tr::delete::Delete; + +use super::ext::ExtensionMeta; + +#[derive(Default, Serialize, Deserialize, Clone)] +pub struct ExtensionMetaList(pub HashMap); + +impl ExtensionMetaList { + pub fn get(&self, key: &str) -> Option<&ExtensionMeta> { + self.0.get(key) + } + pub fn insert(&mut self, key: String, value: ExtensionMeta) { + self.0.insert(key, value); + } + // make it traited + pub async fn remove(&mut self, key: &str) { + if let Some(e) = self.0.remove(key) { + self.delete(e.path()).await + } + } + pub async fn update(&mut self, key: String, value: ExtensionMeta) { + self.remove(&key).await; + self.insert(key, value); + } + pub fn get_list(&self) -> &HashMap { + &self.0 + } +} +impl Delete for ExtensionMetaList {} diff --git a/src/lock/mod.rs b/src/lock/mod.rs index 858f42c..4814a07 100644 --- a/src/lock/mod.rs +++ b/src/lock/mod.rs @@ -1,5 +1,6 @@ pub mod core; pub mod ext; +pub mod ext_metalist; use indicatif::ProgressBar; use log::debug; @@ -7,23 +8,15 @@ use serde::{Deserialize, Serialize}; use tokio::sync::RwLock; use self::core::CoreMeta; -use self::ext::ExtensionMeta; +use self::ext_metalist::ExtensionMetaList; use crate::settings::Settings; -use crate::tr::delete::Delete; +use crate::DICTIONARY; use crate::{ settings::core::Core, tr::{load::Load, save::Save}, }; -use std::collections::HashMap; use std::sync::Arc; -use crate::dictionary::pb_messages::PbMessages; -use lazy_static::lazy_static; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} - #[derive(Default, Serialize, Deserialize, Clone)] pub struct Lock { core: CoreMeta, @@ -54,55 +47,28 @@ impl Lock { } //delete and make the current core the default pub async fn remove_core(&mut self) { - //remove - self.core = CoreMeta::default(); + self.core.remove().await; } - pub async fn remove_nonexistent( - &mut self, - settings: Arc>, - pb: Arc, - ) { + pub async fn remove_defunct(&mut self, settings: Arc>, pb: Arc) { debug!( "fn() remove_nonexistent => keys list: {:#?}", &self.plugins().0 ); - pb.set_message(&DICT.start_remove_nonexist); + pb.set_message(DICTIONARY.defunct().start_remove_defunct()); + + // delete for core you can found in Core::download() if let Some(settings_plugins) = settings.read().await.plugins() { let lock_list = self.plugins().get_list().clone(); for (key, _) in lock_list { if !settings_plugins.items().contains_key(&key) { - pb.set_message(DICT.remove_if_nonexist(&key)); - debug!("{}", DICT.remove_if_nonexist(&key)); + pb.set_message(DICTIONARY.defunct().remove_if_defunct(&key)); + debug!("{}", DICTIONARY.defunct().remove_if_defunct(&key)); self.remove_plugin(&key).await } } } - // TODO: add remover for mods - } -} -#[derive(Default, Serialize, Deserialize, Clone)] -pub struct ExtensionMetaList(HashMap); - -impl ExtensionMetaList { - pub fn get(&self, key: &str) -> Option<&ExtensionMeta> { - self.0.get(key) - } - pub fn insert(&mut self, key: String, value: ExtensionMeta) { - self.0.insert(key, value); - } - // make it traited - pub async fn remove(&mut self, key: &str) { - if let Some(e) = self.0.remove(key) { - self.delete(e.path()).await - } - } - pub async fn update(&mut self, key: String, value: ExtensionMeta) { - self.remove(&key).await; - self.insert(key, value); - } - pub fn get_list(&self) -> &HashMap { - &self.0 + // TODO: add remover for mods } } @@ -112,4 +78,3 @@ impl Save for Lock { impl Load for Lock { const PATH: &'static str = "./lock.toml"; } -impl Delete for ExtensionMetaList {} diff --git a/src/main.rs b/src/main.rs index 422cac1..4b5ce4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,18 @@ pub mod dictionary; pub mod errors; pub mod lock; -pub mod mananger; +pub mod manager; pub mod models; pub mod query; pub mod settings; pub mod tr; use crate::errors::error::Result; +use dictionary::dictionary::MessageDictionary; +use once_cell::sync::Lazy; +static DICTIONARY: Lazy = Lazy::new(|| MessageDictionary::get_dict()); #[tokio::main] async fn main() -> Result<()> { - mananger::run().await + manager::run().await } diff --git a/src/mananger/download.rs b/src/manager/download.rs similarity index 95% rename from src/mananger/download.rs rename to src/manager/download.rs index 7d04ac0..d988132 100644 --- a/src/mananger/download.rs +++ b/src/manager/download.rs @@ -17,14 +17,14 @@ pub async fn download( mpb: Arc, key: Arc, ) -> Result<()> { - let duraction = settings + let duration = settings .read() .await .additions() .unwrap_or(&Additions::default()) - .duraction() + .duration() .unwrap_or(300); - let cooldown = Duration::from_secs(duraction); + let cooldown = Duration::from_secs(duration); loop { '_core_scope: { let lock = Arc::clone(&lock); diff --git a/src/mananger/manage.rs b/src/manager/manage.rs similarity index 60% rename from src/mananger/manage.rs rename to src/manager/manage.rs index 49819ad..726ce23 100644 --- a/src/mananger/manage.rs +++ b/src/manager/manage.rs @@ -1,20 +1,14 @@ -use crate::tr::load::Load; +use crate::DICTIONARY; use std::sync::Arc; use indicatif::MultiProgress; use tokio::sync::{mpsc::Receiver, Mutex, RwLock}; use tokio_util::sync::CancellationToken; -use crate::dictionary::pb_messages::PbMessages; use crate::errors::error::Result; -use crate::mananger::download::download; -use crate::mananger::messages::Messages; +use crate::manager::download::download; +use crate::manager::messages::Messages; use crate::{lock::Lock, settings::Settings}; -use lazy_static::lazy_static; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} pub async fn manage( mut rx: Receiver, @@ -22,34 +16,34 @@ pub async fn manage( settings: Arc>, mpb: Arc, ) -> Result<()> { + let lock = Arc::clone(&lock); + let settings = Arc::clone(&settings); + let mpb = Arc::clone(&mpb); + let key = Arc::new(CancellationToken::new()); loop { - let lock = Arc::clone(&lock); - let settings = Arc::clone(&settings); - let mpb = Arc::clone(&mpb); - let key = Arc::new(CancellationToken::new()); tokio::select! { Some(e) = rx.recv() => match e { Messages::Restart(pb) => { - pb.set_message(&DICT.restart); + pb.set_message(DICTIONARY.manager().restart()); let key = Arc::clone(&key); - pb.set_message(&DICT.stop_iteration); + pb.set_message(DICTIONARY.manager().stop_iteration()); key.cancel(); mpb.clear()?; if key.is_cancelled() { - pb.set_message(&DICT.start_new_iteration); + pb.set_message(DICTIONARY.manager().start_new_iteration()); tokio::spawn(download(settings.clone(), lock.clone(), mpb.clone(), key)); } else { - pb.set_message(&DICT.waiting_new_iteration); + pb.set_message(DICTIONARY.manager().waiting_new_iteration()); } pb.finish_and_clear(); } Messages::Stop(pb) => { - pb.finish_with_message(&DICT.stop_iteration); + pb.finish_with_message(DICTIONARY.manager().stop_iteration()); key.cancelled().await; } Messages::Start(pb) => { let key = Arc::clone(&key); - pb.finish_with_message(&DICT.start_new_iteration); + pb.finish_with_message(DICTIONARY.manager().start_new_iteration()); tokio::spawn(download(settings.clone(), lock.clone(), mpb.clone(), key)); pb.finish_and_clear(); } diff --git a/src/mananger/messages.rs b/src/manager/messages.rs similarity index 100% rename from src/mananger/messages.rs rename to src/manager/messages.rs diff --git a/src/mananger/mod.rs b/src/manager/mod.rs similarity index 79% rename from src/mananger/mod.rs rename to src/manager/mod.rs index 6436bb5..a5924eb 100644 --- a/src/mananger/mod.rs +++ b/src/manager/mod.rs @@ -7,14 +7,13 @@ use std::sync::Arc; use std::time::Duration; use self::watch_changer::watch_changes; -use crate::dictionary::pb_messages::PbMessages; +use crate::dictionary::dictionary::MessageDictionary; use crate::errors::error::Result; use crate::settings::extensions::plugin::Plugin; use crate::tr::save::Save; -use crate::{lock, settings, tr}; +use crate::{lock, settings, tr, DICTIONARY}; use indicatif::{MultiProgress, ProgressBar}; use indicatif_log_bridge::LogWrapper; -use lazy_static::lazy_static; use lock::Lock; use log::warn; use manage::manage; @@ -28,10 +27,6 @@ use tokio::{ }; use tr::load::Load; -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} - pub async fn run() -> Result<()> { let logger = pretty_env_logger::formatted_builder() .filter_level(log::LevelFilter::Info) @@ -41,7 +36,7 @@ pub async fn run() -> Result<()> { LogWrapper::new(mpb_cloned, logger).try_init().unwrap(); // Init It! let pb = mpb.add(ProgressBar::new_spinner()); - pb.set_message(&DICT.intro); + pb.set_message(DICTIONARY.intro()); sleep(Duration::from_secs(1)).await; pb.finish_and_clear(); // @@ -79,8 +74,8 @@ async fn init() -> Result<(Arc, Arc>, Arc Result<(Arc, Arc>, Arc::PATH; + let path = ::PATH; if File::open(path).await.is_err() { - let default = PbMessages::default(); + let default = MessageDictionary::default(); warn!("Create default language file"); let mut file = File::create(path).await?; - let toml_defefault = toml::to_string_pretty(&default)?; - file.write_all(toml_defefault.as_bytes()).await?; + let toml_default = toml::to_string_pretty(&default)?; + file.write_all(toml_default.as_bytes()).await?; } } let mpb: Arc = Arc::new(MultiProgress::new()); diff --git a/src/mananger/watch_changer.rs b/src/manager/watch_changer.rs similarity index 78% rename from src/mananger/watch_changer.rs rename to src/manager/watch_changer.rs index d4d8c55..16fb8a8 100644 --- a/src/mananger/watch_changer.rs +++ b/src/manager/watch_changer.rs @@ -9,16 +9,11 @@ use tokio::sync::mpsc::Sender; use tokio::sync::{Mutex, RwLock}; use crate::errors::error::Result; -use crate::mananger::messages::Messages; +use crate::manager::messages::Messages; use crate::tr::load::Load; +use crate::DICTIONARY; use crate::{lock::Lock, settings::Settings}; -use crate::dictionary::pb_messages::PbMessages; -use lazy_static::lazy_static; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} /// Load downloader module. /// Always check config file. /// Use `token` for canceling minecraft task @@ -44,7 +39,7 @@ pub async fn watch_changes( debug!("Start remove_nonexistent"); let pb = Arc::clone(&pb); let settings = Arc::clone(&settings); - lock.lock().await.remove_nonexistent(settings, pb).await; + lock.lock().await.remove_defunct(settings, pb).await; } // Send start to downloader { @@ -57,23 +52,23 @@ pub async fn watch_changes( while rx.recv().await.is_some() { debug!("find iteration"); let pb = Arc::clone(&pb); - pb.set_message(&DICT.find_changes_in_settings); + pb.set_message(DICTIONARY.config().find_changes_in_settings()); let settings_new = Settings::load().await?; let settings = Arc::clone(&settings); if *settings.read().await != settings_new { - pb.set_message(&DICT.settings_changed); + pb.set_message(DICTIONARY.config().settings_changed()); *settings.write().await = settings_new; { debug!("Start remove_nonexistent"); let pb = Arc::clone(&pb); - lock.lock().await.remove_nonexistent(settings, pb).await; + lock.lock().await.remove_defunct(settings, pb).await; } debug!("Start downloader (message)"); - pb.set_message(&DICT.settings_has_rewrited); + pb.set_message(DICTIONARY.config().settings_rewritten()); manager_tx.send(Messages::Restart(pb)).await?; } else { debug!("Nothing to update (config)"); - pb.set_message(&DICT.settings_same); + pb.set_message(DICTIONARY.config().settings_same()); pb.finish_and_clear(); } } diff --git a/src/models/cores/paper.rs b/src/models/cores/paper.rs index b29f6a6..2150c1a 100644 --- a/src/models/cores/paper.rs +++ b/src/models/cores/paper.rs @@ -1,19 +1,12 @@ use indicatif::ProgressBar; use serde::{Deserialize, Serialize}; -use crate::dictionary::pb_messages::PbMessages; -use crate::tr::load::Load; -use lazy_static::lazy_static; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} - use crate::{ errors::error::{Error, Result}, not_found_build_error, not_found_version_error, settings::core::Core, tr::{hash::ChooseHash, model::core::ModelCore}, + DICTIONARY, }; pub struct Paper(); @@ -58,13 +51,13 @@ impl ModelCore for T { async fn get_link(core: &Core, pb: &ProgressBar) -> Result<(String, ChooseHash, String)> { let core_name = Self::CORE_NAME; // Start work - pb.set_message(&DICT.init_work); + pb.set_message(DICTIONARY.model().init_work()); //get data from core let build = core.build(); let version = core.version(); //find link and version - pb.set_message(&DICT.finding_version); + pb.set_message(DICTIONARY.model().finding_version()); let version = find_version(version, core_name).await?; let verlink = format!( @@ -72,7 +65,7 @@ impl ModelCore for T { core_name, version ); - pb.set_message(&DICT.make_link); + pb.set_message(DICTIONARY.model().make_link()); let build_list: BuildList = reqwest::get(verlink).await?.json().await?; let build_list = build_list.builds.as_slice(); @@ -113,20 +106,20 @@ impl ModelCore for T { } //Find version in version list, if exist give out version or give error -async fn find_version(version: &str, core_name: &str) -> Result { +async fn find_version(version: Option<&String>, core_name: &str) -> Result { let link = format!("https://api.papermc.io/v2/projects/{}", core_name); let version_list = { let version_list: VersionList = reqwest::get(link).await?.json().await?; version_list.versions }; match version { - "Latest" => match version_list.last() { + None => match version_list.last() { Some(e) => Ok(e.to_owned()), None => not_found_version_error!("Latest"), }, - _ => { - if version_list.contains(&version.to_string()) { - Ok(version.to_owned()) + Some(e) => { + if version_list.contains(&e) { + Ok(e.to_owned()) } else { not_found_version_error!(version) } diff --git a/src/models/cores/purpur.rs b/src/models/cores/purpur.rs index 9c375da..95c9e6e 100644 --- a/src/models/cores/purpur.rs +++ b/src/models/cores/purpur.rs @@ -81,19 +81,19 @@ impl ModelCore for Purpur { } //Find version in version list, if exist give out version or give error -async fn find_version(version: &str) -> Result { +async fn find_version(version: Option<&String>) -> Result { let version_list = { let version_list: VersionList = reqwest::get(MAIN_LINK).await?.json().await?; version_list.versions }; match version { - "Latest" => match version_list.last() { + None => match version_list.last() { Some(e) => Ok(e.to_owned()), None => not_found_version_error!("Latest"), }, - _ => { - if version_list.contains(&version.to_string()) { - Ok(version.to_owned()) + Some(e) => { + if version_list.contains(&e) { + Ok(e.to_owned()) } else { not_found_version_error!(version) } diff --git a/src/models/cores/vanilla.rs b/src/models/cores/vanilla.rs index 897a08e..e816f42 100644 --- a/src/models/cores/vanilla.rs +++ b/src/models/cores/vanilla.rs @@ -91,18 +91,16 @@ impl ModelCore for Vanilla { } ///Return `url` which get a json that contain links of all versions -async fn find_version(version: &str) -> Result<(String, String)> { +async fn find_version(version: Option<&String>) -> Result<(String, String)> { const LINK: &str = "https://launchermeta.mojang.com/mc/game/version_manifest.json"; // trace!("Start find version of core!"); let response = reqwest::get(LINK).await?; let vanilla: Vanilla = response.json().await?; - let local_version = { - if version == "Latest" { - vanilla.latest.release - } else { - version.to_string() - } + let local_version = match version { + Some(e) => e.to_owned(), + None => vanilla.latest.release, }; + // info!("Need to find: {}", &local_version); // Use a temporary variable to hold the found version and URL diff --git a/src/models/extensions/modrinth.rs b/src/models/extensions/modrinth.rs index a3525c6..b044082 100644 --- a/src/models/extensions/modrinth.rs +++ b/src/models/extensions/modrinth.rs @@ -48,7 +48,7 @@ impl ModelExtensions for ModrinthData { async fn get_link( ext: &Self::Ext, name: &str, - game_version: &str, + game_version: Option<&String>, loader: &str, ) -> Result<(Self::Link, ChooseHash, Self::Version)> { let channel = ext.channel().get_str().await.to_string(); @@ -62,8 +62,8 @@ impl ModelExtensions for ModrinthData { } }; let query = { - match game_version.to_lowercase().as_str() { - "latest" => { + match game_version { + None => { vec![ // ("game_version", format!("[\"{}\"]", game_version)), ("loaders", format!("[\"{}\"]", loader)), @@ -72,9 +72,9 @@ impl ModelExtensions for ModrinthData { ] } - _ => { + Some(e) => { vec![ - ("game_version", format!("[\"{}\"]", game_version)), + ("game_version", format!("[\"{}\"]", e)), ("loaders", format!("[\"{}\"]", loader)), ("featured", true.to_string()), ("version_type", channel), diff --git a/src/settings/additions.rs b/src/settings/additions.rs index 82c309f..fe973bd 100644 --- a/src/settings/additions.rs +++ b/src/settings/additions.rs @@ -8,21 +8,21 @@ pub struct Additions { // git key #[serde(default)] key: Option, - // duraction of delay between download intervals - #[serde(default = "duraction_default")] - duraction: Option, + // duration of delay between download intervals + #[serde(default = "duration_default")] + duration: Option, } -fn duraction_default() -> Option { +fn duration_default() -> Option { Some(300) } impl Additions { - pub fn new(source: Option, key: Option, duraction: Option) -> Self { + pub fn new(source: Option, key: Option, duration: Option) -> Self { Self { source, key, - duraction, + duration, } } @@ -34,7 +34,7 @@ impl Additions { self.key.as_ref() } - pub fn duraction(&self) -> Option { - self.duraction + pub fn duration(&self) -> Option { + self.duration } } diff --git a/src/settings/core.rs b/src/settings/core.rs index 7530df7..7f35da0 100644 --- a/src/settings/core.rs +++ b/src/settings/core.rs @@ -1,14 +1,11 @@ -use crate::tr::load::Load; use std::{sync::Arc, time::Duration}; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use lazy_static::lazy_static; use log::{debug, trace}; use serde::{Deserialize, Serialize}; use tokio::{sync::Mutex, time::sleep}; use crate::{ - dictionary::pb_messages::PbMessages, errors::error::Result, lock::{core::CoreMeta, Lock}, models::cores::{ @@ -16,40 +13,28 @@ use crate::{ waterfall::Waterfall, }, pb, - tr::{ - delete::Delete, download::Download, hash::ChooseHash, model::core::ModelCore, save::Save, - }, + tr::{download::Download, hash::ChooseHash, model::core::ModelCore, save::Save}, + DICTIONARY, }; -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} - #[derive(Deserialize, Serialize, Debug, Default, PartialEq, Clone)] pub struct Core { - // Ядро + // Core #[serde(default)] provider: Provider, - // Версия ядра - // Change to Enum! - #[serde(default = "version")] - version: String, - // Версия билда ядра + // Version of Core + version: Option, + // Build version of Core #[serde(default)] build: Option, - // Приостановить обновление + // Freeze updates? #[serde(default)] freeze: bool, - // Нужно обновить + // Force update it? #[serde(default)] force_update: bool, } -fn version() -> String { - // warn!("We use default core path!"); - "Latest".to_string() -} - impl Core { pub fn to_meta(self, build: String) -> CoreMeta { let path = format!("./{}.jar", &self.provider.as_str().to_string()); @@ -60,7 +45,7 @@ impl Core { &self.provider } - pub fn version(&self) -> &str { + pub fn version(&self) -> Option<&String> { self.version.as_ref() } @@ -81,7 +66,7 @@ impl Core { } pub fn set_version(&mut self, version: String) { - self.version = version; + self.version = Some(version); } pub fn set_build(&mut self, build: Option) { @@ -95,7 +80,7 @@ impl Core { pub fn set_force_update(&mut self, force_update: bool) { self.force_update = force_update; } - /// Скачиваем `Core` и сохраняем его по стандартному пути. + /// Download `Core` and save it to standard path. pub async fn download(&self, lock: Arc>, mpb: Arc) -> Result<()> { let pb = pb!(mpb, self.provider.as_str()); @@ -104,29 +89,29 @@ impl Core { if let Some(e) = lock.lock().await.core().build() { trace!("lock build: {} / build: {}", &e, &build); if *e == build && (!self.force_update || self.freeze) { - pb.set_message(&DICT.doest_need_to_update); + pb.set_message(DICTIONARY.downloader().doest_need_to_update()); sleep(Duration::from_secs(1)).await; pb.finish_and_clear(); return Ok(()); } } - pb.set_message(&DICT.download_file); + pb.set_message(DICTIONARY.downloader().download_file()); let file = Core::get_file(link, hash, &pb).await?; debug!("file: => {} | got", self.provider().as_str()); - debug!("file: => {} | saving", self.provider().as_str()); - pb.set_message(&DICT.delete_exist_version); + pb.set_message(DICTIONARY.downloader().delete_exist_version()); { - self.delete(lock.lock().await.core().path()).await; + lock.lock().await.remove_core().await; } - pb.set_message(&DICT.saving_file); + debug!("file: => {} | saving", self.provider().as_str()); + pb.set_message(DICTIONARY.downloader().saving_file()); Core::save_bytes(file, self.provider().as_str()).await?; - debug!("file: => {} | saved", self.provider().as_str()); + debug!("Data: => {} | start locking", self.provider().as_str()); - pb.set_message(&DICT.write_to_lock); + pb.set_message(DICTIONARY.downloader().write_to_lock()); { let mut lock = lock.lock().await; *lock.core_mut() = self.clone().to_meta(build); @@ -138,7 +123,7 @@ impl Core { self.provider().as_str() ); - pb.set_message(&DICT.done); + pb.set_message(DICTIONARY.downloader().done()); pb.finish_and_clear(); Ok(()) } @@ -194,4 +179,3 @@ impl Download for Core {} impl Save for Core { const PATH: &'static str = "./"; } -impl Delete for Core {} diff --git a/src/settings/extensions/plugin.rs b/src/settings/extensions/plugin.rs index b3338a7..fe70c77 100644 --- a/src/settings/extensions/plugin.rs +++ b/src/settings/extensions/plugin.rs @@ -49,11 +49,11 @@ impl Plugin { self.force_update } /// Get link from models. - pub async fn get_link<'a>( - &'a self, - name: &'a str, - game_version: &'a str, - loader: &'a str, + pub async fn get_link( + &self, + name: &str, + game_version: Option<&String>, + loader: &str, ) -> Result<(String, ChooseHash, String)> { match self.source { Sources::Hangar => todo!(), diff --git a/src/settings/extensions/plugins.rs b/src/settings/extensions/plugins.rs index c1ab3d9..860d34c 100644 --- a/src/settings/extensions/plugins.rs +++ b/src/settings/extensions/plugins.rs @@ -1,27 +1,20 @@ -use crate::tr::load::Load; use std::collections::HashMap; use std::sync::Arc; use futures_util::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use lazy_static::lazy_static; use log::debug; use serde::{Deserialize, Serialize}; use tokio::sync::Mutex; use tokio::task::JoinHandle; use super::plugin::Plugin; -use crate::dictionary::pb_messages::PbMessages; use crate::errors::error::Result; use crate::lock::ext::ExtensionMeta; use crate::lock::Lock; -use crate::pb; use crate::tr::hash::ChooseHash; use crate::tr::{download::Download, save::Save}; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} +use crate::{pb, DICTIONARY}; #[derive(Deserialize, Serialize, Debug, Default, PartialEq)] pub struct Plugins(HashMap); @@ -38,7 +31,7 @@ impl Plugins { pub async fn download_all( &self, loader: &str, - game_version: &str, + game_version: Option<&String>, lock: Arc>, mpb: Arc, ) -> Result<()> { @@ -48,10 +41,10 @@ impl Plugins { Ok(()) } - /// Check lock extensions with config extesions + /// Check lock extensions with config extensions async fn check_plugins( &self, - game_version: &str, + game_version: Option<&String>, loader: &str, mpb: Arc, lock: &Arc>, @@ -61,7 +54,7 @@ impl Plugins { debug!("check extension: {}", &name); // Get link let (link, hash, build) = plugin.get_link(name, game_version, loader).await?; - debug!("got a link to the extesion: {}", &name); + debug!("got a link to the extension: {}", &name); let pb = pb!(mpb, name); debug!("check meta: {}", &name); // Check meta @@ -70,7 +63,7 @@ impl Plugins { // Need to download? if *local_build == build && !plugin.force_update() || plugin.freeze() { debug!("Does't need to update: {}", &name); - pb.set_message(&DICT.doest_need_to_update); + pb.set_message(DICTIONARY.downloader().doest_need_to_update()); pb.finish_and_clear(); continue; } @@ -96,17 +89,17 @@ fn make_handle_list( debug!("Remove exist version of {}", &name); { - pb.set_message(&DICT.delete_exist_version); + pb.set_message(DICTIONARY.downloader().delete_exist_version()); lock.lock().await.remove_plugin(&name).await; } debug!("Saving {}", &name); - pb.set_message(&DICT.saving_file); + pb.set_message(DICTIONARY.downloader().saving_file()); Plugin::save_bytes(file, &name).await?; debug!("Write data to lock file {}", &name); - pb.set_message(&DICT.write_to_lock); + pb.set_message(DICTIONARY.downloader().write_to_lock()); { lock.lock() .await @@ -119,7 +112,7 @@ fn make_handle_list( debug!("Save meta data to lock of {}", &name); lock.lock().await.save().await?; - pb.set_message(&DICT.done); + pb.set_message(DICTIONARY.downloader().done()); pb.finish_and_clear(); Ok(()) diff --git a/src/tr/download.rs b/src/tr/download.rs index fa3ef36..4021485 100644 --- a/src/tr/download.rs +++ b/src/tr/download.rs @@ -1,18 +1,10 @@ use super::hash::ChooseHash; -use crate::errors::error::Result; +use crate::{errors::error::Result, DICTIONARY}; use async_trait::async_trait; use bytes::{Bytes, BytesMut}; use futures_util::StreamExt; use indicatif::ProgressBar; -use crate::dictionary::pb_messages::PbMessages; -use crate::tr::load::Load; -use lazy_static::lazy_static; - -lazy_static! { - static ref DICT: PbMessages = PbMessages::load_sync().unwrap(); -} - #[async_trait] pub trait Download { async fn get_file(link: String, hash: ChooseHash, pb: &ProgressBar) -> Result { @@ -22,7 +14,7 @@ pub trait Download { let size = response.content_length().unwrap_or(0); pb.set_length(size); - pb.set_message(&DICT.download_file); + pb.set_message(DICTIONARY.downloader().download_file()); let mut size_upload = 0_u64; let mut content = BytesMut::new(); @@ -33,10 +25,10 @@ pub trait Download { pb.set_position(size_upload); content.extend_from_slice(&chunk) } - pb.set_message(&DICT.calculate_hash); + pb.set_message(DICTIONARY.downloader().calculate_hash()); hash.calculate_hash(&*content).await?; // End - pb.set_message(&DICT.file_downloaded); + pb.set_message(DICTIONARY.downloader().file_downloaded()); Ok(content.freeze()) } } diff --git a/src/tr/model/extension.rs b/src/tr/model/extension.rs index 3acb919..e0b1318 100644 --- a/src/tr/model/extension.rs +++ b/src/tr/model/extension.rs @@ -8,7 +8,7 @@ pub trait ModelExtensions { fn get_link( ext: &Self::Ext, name: &str, - game_version: &str, + game_version: Option<&String>, loader: &str, ) -> impl std::future::Future> + Send; }