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
use std::fmt;
use crate::unity::Component;

#[derive(PartialEq, Eq, Hash, Debug, Clone)]
pub enum InstallVariant {
    Android,
    Ios,
    WebGl,
    Linux,
    Windows,
    WindowsMono,
    Editor,
}

impl fmt::Display for InstallVariant {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match *self {
            InstallVariant::Android => write!(f, "android"),
            InstallVariant::Ios => write!(f, "ios"),
            InstallVariant::WebGl => write!(f, "webgl"),
            InstallVariant::Linux => write!(f, "linux"),
            InstallVariant::Windows => write!(f, "windows"),
            InstallVariant::WindowsMono => write!(f, "windows-mono"),
            _ => write!(f, "editor"),
        }
    }
}

impl From<Component> for InstallVariant {
    fn from(component: Component) -> Self {
        match component {
            Component::Android => InstallVariant::Android,
            Component::Ios => InstallVariant::Ios,
            Component::WebGl => InstallVariant::WebGl,
            Component::Linux => InstallVariant::Linux,
            Component::Windows => InstallVariant::Windows,
            Component::WindowsMono => InstallVariant::WindowsMono,
            _ => InstallVariant::Editor,
        }
    }
}

impl From<InstallVariant> for Component {
    fn from(component: InstallVariant) -> Self {
        match component {
            InstallVariant::Android => Component::Android,
            InstallVariant::Ios => Component::Ios,
            InstallVariant::WebGl => Component::WebGl,
            InstallVariant::Linux => Component::Linux,
            InstallVariant::Windows => Component::Windows,
            InstallVariant::WindowsMono => Component::WindowsMono,
            InstallVariant::Editor => Component::Editor,
        }
    }
}