-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a85427b
commit 732dbbc
Showing
4 changed files
with
175 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
pub use crate::header::types::{EnhancedSync, WhiskyVersion, WinVersion}; | ||
use iso8601::Date; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
pub mod types; | ||
|
||
#[derive(Default)] | ||
pub struct LogHeader { | ||
pub whisky_version: WhiskyVersion, | ||
pub date: Date, | ||
pub macos_version: WhiskyVersion, | ||
pub bottle_name: String, | ||
pub bottle_url: String, | ||
pub wine_version: WhiskyVersion, | ||
pub windows_version: WinVersion, | ||
pub enhanced_sync: EnhancedSync, | ||
pub metal_hud: bool, | ||
pub metal_trace: bool, | ||
pub arguments: String, | ||
} | ||
|
||
impl Display for LogHeader { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "Whisky Version: {}\n", self.whisky_version.0)?; | ||
write!(f, "Date: {}\n", self.date)?; | ||
write!(f, "macOS Version: {}\n", self.macos_version.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
use std::fmt::{Display, Formatter}; | ||
use semver::{BuildMetadata, Prerelease, Version}; | ||
use std::str::FromStr; | ||
|
||
#[derive(Default)] | ||
pub enum WinVersion { | ||
WinXP, | ||
Win7, | ||
Win8, | ||
Wine81, | ||
#[default] | ||
Win10, | ||
} | ||
|
||
impl Display for WinVersion { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
WinVersion::WinXP => write!(f, "Windows XP"), | ||
WinVersion::Win7 => write!(f, "Windows 7"), | ||
WinVersion::Win8 => write!(f, "Windows 8"), | ||
WinVersion::Wine81 => write!(f, "Windows 8.1"), | ||
WinVersion::Win10 => write!(f, "Windows 10"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for WinVersion { | ||
type Err = (); | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"winxp64" => Ok(WinVersion::WinXP), | ||
"win7" => Ok(WinVersion::Win7), | ||
"win8" => Ok(WinVersion::Win8), | ||
"win81" => Ok(WinVersion::Wine81), | ||
"win10" => Ok(WinVersion::Win10), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub enum EnhancedSync { | ||
None, | ||
ESync, | ||
#[default] | ||
MSync, | ||
} | ||
|
||
impl Display for EnhancedSync { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
EnhancedSync::None => write!(f, "None"), | ||
EnhancedSync::ESync => write!(f, "ESync"), | ||
EnhancedSync::MSync => write!(f, "MSync"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for EnhancedSync { | ||
type Err = (); | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"none" => Ok(EnhancedSync::None), | ||
"esync" => Ok(EnhancedSync::ESync), | ||
"msync" => Ok(EnhancedSync::MSync), | ||
_ => Err(()), | ||
} | ||
} | ||
} | ||
|
||
pub struct WhiskyVersion(pub Version); | ||
impl Default for WhiskyVersion { | ||
fn default() -> Self { | ||
return WhiskyVersion { | ||
0: Version { | ||
major: 0, | ||
minor: 0, | ||
patch: 0, | ||
pre: Prerelease::EMPTY, | ||
build: BuildMetadata::EMPTY, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters