Initial setup
This commit is contained in:
38
src/config.rs
Normal file
38
src/config.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum MinecraftType {
|
||||
Vanilla,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Version {
|
||||
pub major: u32,
|
||||
pub minor: u32,
|
||||
pub patch: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Snapshot {
|
||||
pub year: u32,
|
||||
pub week: u32,
|
||||
pub build: char,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum MinecraftVersion {
|
||||
Release(Version),
|
||||
Snapshot(Snapshot),
|
||||
}
|
||||
|
||||
impl Display for Version {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Snapshot {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}w{:02}{}", self.year, self.week, self.build)
|
||||
}
|
||||
}
|
||||
9
src/error.rs
Normal file
9
src/error.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
pub enum Error {
|
||||
#[error("Undefined error")]
|
||||
Generic,
|
||||
}
|
||||
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
9
src/instance.rs
Normal file
9
src/instance.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::config::MinecraftVersion;
|
||||
|
||||
pub struct InstanceData {
|
||||
pub root_dir: PathBuf,
|
||||
pub jar_path: PathBuf,
|
||||
pub version: MinecraftVersion,
|
||||
}
|
||||
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod instance;
|
||||
Reference in New Issue
Block a user