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
mod err;
use std::fmt;
use std::char;
pub use self::err::{SheetError, Result};
#[repr(u32)]
#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]
pub enum Sheet {
None = 0x5f,
Bust = 0x62,
}
impl Sheet {
pub fn new(content: &str) -> Result<Self> {
match content {
"bust" => Ok(Sheet::Bust),
"none" => Ok(Sheet::None),
name => Err(SheetError::UnknownSheet(name.to_string())),
}
}
pub fn get_name(&self) -> &'static str {
match *self {
Sheet::None => "None",
Sheet::Bust => "Bust",
}
}
}
impl fmt::Display for Sheet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", unsafe {
char::from_u32_unchecked(*self as u32)
})
}
}
impl Default for Sheet {
fn default() -> Sheet {
Sheet::None
}
}