revive_llvm_builder/
ccache_variant.rs

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