From 5a2175856a74e187eb2e952ecfa6136e37bd6c41 Mon Sep 17 00:00:00 2001 From: TOwInOK <60252419+TOwInOK@users.noreply.github.com> Date: Sun, 3 Mar 2024 00:16:37 +0700 Subject: [PATCH] cargo fmt --- .vscode/launch.json | 45 +++++++++++++++++++++++ Cargo.lock | 28 +++++++-------- Cargo.toml | 2 +- src/config/datapack.rs | 18 +++++++--- src/config/errors.rs | 4 --- src/config/mod.rs | 81 ++++++++++++++++++++---------------------- src/config/plugin.rs | 17 ++++++--- src/config/version.rs | 6 ++-- src/main.rs | 6 ++-- 9 files changed, 132 insertions(+), 75 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2a7ee5e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Используйте IntelliSense, чтобы узнать о возможных атрибутах. + // Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов. + // Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'minecraft_addon_controller'", + "cargo": { + "args": [ + "build", + "--bin=minecraft_addon_controller", + "--package=minecraft_addon_controller" + ], + "filter": { + "name": "minecraft_addon_controller", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'minecraft_addon_controller'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=minecraft_addon_controller", + "--package=minecraft_addon_controller" + ], + "filter": { + "name": "minecraft_addon_controller", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 7a16f93..fd23df1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,20 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "MinecraftAddonController" -version = "0.0.1" -dependencies = [ - "log", - "pretty_env_logger", - "reqwest", - "serde", - "serde_json", - "thiserror", - "tokio", - "toml", -] - [[package]] name = "addr2line" version = "0.21.0" @@ -450,6 +436,20 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minecraft_addon_controller" +version = "0.0.1" +dependencies = [ + "log", + "pretty_env_logger", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "toml", +] + [[package]] name = "miniz_oxide" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 4566597..d27e9f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "MinecraftAddonController" +name = "minecraft_addon_controller" version = "0.0.1" authors = ["TOwInOK"] edition = "2021" diff --git a/src/config/datapack.rs b/src/config/datapack.rs index 3749514..511068c 100644 --- a/src/config/datapack.rs +++ b/src/config/datapack.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; ///Lists of Datapacks #[derive(Deserialize, Serialize, Debug)] @@ -14,12 +14,20 @@ pub struct Datapack { } impl Datapack { - fn new(modrinth: Option>, spigot: Option>, paper: Option>, frozen: Option>) -> Self { - Self { modrinth, spigot, paper, frozen } + fn new( + modrinth: Option>, + spigot: Option>, + paper: Option>, + frozen: Option>, + ) -> Self { + Self { + modrinth, + spigot, + paper, + frozen, + } } pub fn default() -> Self { Datapack::new(None, None, None, None) } } - - diff --git a/src/config/errors.rs b/src/config/errors.rs index 87fbbfe..e948fdc 100644 --- a/src/config/errors.rs +++ b/src/config/errors.rs @@ -3,14 +3,10 @@ use thiserror::Error; pub enum DownloadErrors { #[error("Загрузка прекращенна потому что: {0}")] DownloadCorrapt(String), - } - #[derive(Error, Debug)] pub enum ConfigErrors { #[error("Загрузка файла не была успешна: {0}")] LoadCorrapt(String), - } - diff --git a/src/config/mod.rs b/src/config/mod.rs index 0dd92e2..bcd69be 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,19 +1,17 @@ mod datapack; mod errors; +mod model; mod plugin; mod version; -mod model; - -use std::default; +use datapack::*; +use errors::*; use log::{error, info}; +use plugin::Plugin; +use serde::{Deserialize, Serialize}; +use std::default; use tokio::fs; -use errors::*; -use serde::{Serialize, Deserialize}; use version::Versions; -use datapack::*; -use plugin::Plugin; - ///Struct to load config from toml file. #[derive(Deserialize, Serialize, Debug)] @@ -25,10 +23,13 @@ pub struct Config { impl Config { fn new(version: Versions, plugins: Option, datapacks: Option) -> Self { - Self { version, plugins, datapacks } + Self { + version, + plugins, + datapacks, + } } - fn default() -> Self { Config::new(Versions::default(), None, None) } @@ -62,41 +63,37 @@ impl Config { } }; config -} - - + } -pub async fn download(config: Config) -> Result<(), DownloadErrors> { - let file = config.download_core().await; - todo!() -} + pub async fn download(config: Config) -> Result<(), DownloadErrors> { + let file = config.download_core().await; + todo!() + } -async fn download_plugins() -> Result<(), DownloadErrors> { - todo!() -} -async fn download_mods() -> Result<(), DownloadErrors> { - todo!() -} -async fn download_datapacks() -> Result<(), DownloadErrors> { - todo!() -} + async fn download_plugins() -> Result<(), DownloadErrors> { + todo!() + } + async fn download_mods() -> Result<(), DownloadErrors> { + todo!() + } + async fn download_datapacks() -> Result<(), DownloadErrors> { + todo!() + } -async fn download_core(self) -> Result, DownloadErrors> { - match self.version { - Versions::Purpur(ver, freez) => { - if !freez { - //We don't need to download - return Ok(None) ; + async fn download_core(self) -> Result, DownloadErrors> { + match self.version { + Versions::Purpur(ver, freez) => { + if !freez { + //We don't need to download + return Ok(None); + } + //use if error + Err(DownloadErrors::DownloadCorrapt("ff".to_string())) } - //use if error - Err(DownloadErrors::DownloadCorrapt("ff".to_string())) - }, - Versions::Paper(ver, freez) => todo!(), - Versions::Spigot(ver, freez) => todo!(), - Versions::Bucket(ver, freez) => todo!(), - Versions::Vanila(ver, freez) => todo!(), + Versions::Paper(ver, freez) => todo!(), + Versions::Spigot(ver, freez) => todo!(), + Versions::Bucket(ver, freez) => todo!(), + Versions::Vanila(ver, freez) => todo!(), + } } } - -} - diff --git a/src/config/plugin.rs b/src/config/plugin.rs index ec67352..f99aea3 100644 --- a/src/config/plugin.rs +++ b/src/config/plugin.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; ///Lists of plugins #[derive(Deserialize, Serialize, Debug)] @@ -14,11 +14,20 @@ pub struct Plugin { } impl Plugin { - fn new(modrinth: Option>, spigot: Option>, paper: Option>, frozen: Option>) -> Self { - Self { modrinth, spigot, paper, frozen } + fn new( + modrinth: Option>, + spigot: Option>, + paper: Option>, + frozen: Option>, + ) -> Self { + Self { + modrinth, + spigot, + paper, + frozen, + } } pub fn default() -> Self { Plugin::new(None, None, None, None) } } - diff --git a/src/config/version.rs b/src/config/version.rs index a0fc97c..852d59f 100644 --- a/src/config/version.rs +++ b/src/config/version.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; ///Cores include version #[derive(Deserialize, Serialize, Debug)] @@ -13,6 +13,6 @@ pub enum Versions { impl Default for Versions { fn default() -> Self { - Versions::Vanila("1.20.4".to_string(), false) + Versions::Vanila("latest".to_string(), false) } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 9984b71..84d90c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,9 @@ use config::Config; #[tokio::main] async fn main() { - pretty_env_logger::formatted_builder().filter_level(log::LevelFilter::Debug).init(); + pretty_env_logger::formatted_builder() + .filter_level(log::LevelFilter::Debug) + .init(); //Load Config file let path = "./config.toml".to_string(); @@ -12,5 +14,5 @@ async fn main() { match Config::download(config).await { Ok(_) => todo!(), Err(_) => todo!(), - } + } }