compiler_llvm_builder/
ccache_variant.rs

1//!
2//! Compiler cache variants.
3//!
4
5///
6/// The list compiler cache variants to be used as constants.
7///
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum CcacheVariant {
10    /// Standard ccache.
11    Ccache,
12    /// Mozilla's sccache.
13    Sccache,
14}
15
16impl std::str::FromStr for CcacheVariant {
17    type Err = String;
18
19    fn from_str(value: &str) -> Result<Self, Self::Err> {
20        match value {
21            "ccache" => Ok(Self::Ccache),
22            "sccache" => Ok(Self::Sccache),
23            value => Err(format!("Unsupported ccache variant: `{}`", value)),
24        }
25    }
26}
27
28impl std::fmt::Display for CcacheVariant {
29    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
30        match self {
31            Self::Ccache => write!(f, "ccache"),
32            Self::Sccache => write!(f, "sccache"),
33        }
34    }
35}