lf2_parse/element/w_point/
w_point_kind.rs1use std::str::FromStr;
2
3use crate::WPointKindParseError;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum WPointKind {
8 Holding = 1,
10 Held = 2,
12 Dropping = 3,
14}
15
16impl Default for WPointKind {
17 fn default() -> Self {
18 Self::Holding
19 }
20}
21
22impl FromStr for WPointKind {
23 type Err = WPointKindParseError;
24
25 fn from_str(s: &str) -> Result<WPointKind, WPointKindParseError> {
26 s.parse::<u32>()
27 .map_err(WPointKindParseError::ParseIntError)
28 .and_then(|value| match value {
29 1 => Ok(WPointKind::Holding),
30 2 => Ok(WPointKind::Held),
31 3 => Ok(WPointKind::Dropping),
32 value => Err(WPointKindParseError::InvalidValue(value)),
33 })
34 }
35}