1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std::{
fmt::{Debug, Display},
str::FromStr,
};
use crate::{error::Kind, throw};
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum RuntimeOption {
log, wined3d, nod3d11, nod3d10, noesync, nofsync, enablenvapi, }
impl Display for RuntimeOption {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let opt = match self {
RuntimeOption::log => "PROTON_LOG",
RuntimeOption::wined3d => "PROTON_USE_WINED3D",
RuntimeOption::nod3d11 => "PROTON_NO_D3D11",
RuntimeOption::nod3d10 => "PROTON_NO_D3D10",
RuntimeOption::noesync => "PROTON_NO_ESYNC",
RuntimeOption::nofsync => "PROTON_NO_FSYNC",
RuntimeOption::enablenvapi => "PROTON_ENABLE_NVAPI",
};
write!(f, "{}", opt)
}
}
impl FromStr for RuntimeOption {
type Err = crate::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"log" => Ok(Self::log),
"wined3d" => Ok(Self::wined3d),
"nod3d11" => Ok(Self::nod3d11),
"nod3d10" => Ok(Self::nod3d10),
"noesync" => Ok(Self::noesync),
"nofsync" => Ok(Self::nofsync),
"enablenvapi" | "nvapi" => Ok(Self::enablenvapi),
_ => throw!(Kind::ParseRuntimeOpt, "{} is not a runtime option", s),
}
}
}