| 1 |
use std::str::FromStr; |
| 2 |
|
| 3 |
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq)] |
| 4 |
pub enum WorkMode { |
| 5 |
#[default] |
| 6 |
Normal, // generate widgets etc. |
| 7 |
Sys, // generate -sys with FFI |
| 8 |
Doc, // generate documentation file |
| 9 |
DisplayNotBound, // Show not bound types |
| 10 |
} |
| 11 |
|
| 12 |
impl WorkMode { |
| 13 |
pub fn is_normal(self) -> bool { |
| 14 |
matches!(self, Self::Normal) |
| 15 |
} |
| 16 |
|
| 17 |
pub fn is_generate_rust_files(self) -> bool { |
| 18 |
matches!(self, Self::Normal | Self::Sys) |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
impl FromStr for WorkMode { |
| 23 |
type Err = String; |
| 24 |
fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 25 |
match s { |
| 26 |
"normal" => Ok(Self::Normal), |
| 27 |
"sys" => Ok(Self::Sys), |
| 28 |
"doc" => Ok(Self::Doc), |
| 29 |
"not_bound" => Ok(Self::DisplayNotBound), |
| 30 |
_ => Err(format!("Wrong work mode '{s}'")), |
| 31 |
} |
| 32 |
} |
| 33 |
} |