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
//!
//! The ZKsync LLVM build type.
//!

///
/// The ZKsync LLVM build type.
///
#[derive(Debug, PartialEq, Eq)]
pub enum BuildType {
    /// The debug build.
    Debug,
    /// The release build.
    Release,
    /// The release with debug info build.
    RelWithDebInfo,
    /// The minimal size release build.
    MinSizeRel,
}

impl std::str::FromStr for BuildType {
    type Err = String;

    fn from_str(value: &str) -> Result<Self, Self::Err> {
        match value {
            "Debug" => Ok(Self::Debug),
            "Release" => Ok(Self::Release),
            "RelWithDebInfo" => Ok(Self::RelWithDebInfo),
            "MinSizeRel" => Ok(Self::MinSizeRel),
            value => Err(format!("Unsupported build type: `{}`", value)),
        }
    }
}

impl std::fmt::Display for BuildType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Debug => write!(f, "Debug"),
            Self::Release => write!(f, "Release"),
            Self::RelWithDebInfo => write!(f, "RelWithDebInfo"),
            Self::MinSizeRel => write!(f, "MinSizeRel"),
        }
    }
}