Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed Mar 2, 2024
1 parent 667aa32 commit 5a21758
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 75 deletions.
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "MinecraftAddonController"
name = "minecraft_addon_controller"
version = "0.0.1"
authors = ["TOwInOK"]
edition = "2021"
Expand Down
18 changes: 13 additions & 5 deletions src/config/datapack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

///Lists of Datapacks
#[derive(Deserialize, Serialize, Debug)]
Expand All @@ -14,12 +14,20 @@ pub struct Datapack {
}

impl Datapack {
fn new(modrinth: Option<Vec<String>>, spigot: Option<Vec<String>>, paper: Option<Vec<String>>, frozen: Option<Vec<String>>) -> Self {
Self { modrinth, spigot, paper, frozen }
fn new(
modrinth: Option<Vec<String>>,
spigot: Option<Vec<String>>,
paper: Option<Vec<String>>,
frozen: Option<Vec<String>>,
) -> Self {
Self {
modrinth,
spigot,
paper,
frozen,
}
}
pub fn default() -> Self {
Datapack::new(None, None, None, None)
}
}


4 changes: 0 additions & 4 deletions src/config/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ use thiserror::Error;
pub enum DownloadErrors {
#[error("Загрузка прекращенна потому что: {0}")]
DownloadCorrapt(String),

}


#[derive(Error, Debug)]
pub enum ConfigErrors {
#[error("Загрузка файла не была успешна: {0}")]
LoadCorrapt(String),

}

81 changes: 39 additions & 42 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -25,10 +23,13 @@ pub struct Config {

impl Config {
fn new(version: Versions, plugins: Option<Plugin>, datapacks: Option<Datapack>) -> Self {
Self { version, plugins, datapacks }
Self {
version,
plugins,
datapacks,
}
}


fn default() -> Self {
Config::new(Versions::default(), None, None)
}
Expand Down Expand Up @@ -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<Option<()>, 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<Option<()>, 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!(),
}
}
}

}

17 changes: 13 additions & 4 deletions src/config/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

///Lists of plugins
#[derive(Deserialize, Serialize, Debug)]
Expand All @@ -14,11 +14,20 @@ pub struct Plugin {
}

impl Plugin {
fn new(modrinth: Option<Vec<String>>, spigot: Option<Vec<String>>, paper: Option<Vec<String>>, frozen: Option<Vec<String>>) -> Self {
Self { modrinth, spigot, paper, frozen }
fn new(
modrinth: Option<Vec<String>>,
spigot: Option<Vec<String>>,
paper: Option<Vec<String>>,
frozen: Option<Vec<String>>,
) -> Self {
Self {
modrinth,
spigot,
paper,
frozen,
}
}
pub fn default() -> Self {
Plugin::new(None, None, None, None)
}
}

6 changes: 3 additions & 3 deletions src/config/version.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

///Cores include version
#[derive(Deserialize, Serialize, Debug)]
Expand All @@ -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)
}
}
}
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -12,5 +14,5 @@ async fn main() {
match Config::download(config).await {
Ok(_) => todo!(),
Err(_) => todo!(),
}
}
}

0 comments on commit 5a21758

Please sign in to comment.