use std::str::FromStr;
use crate::WPointKindParseError;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WPointKind {
Holding = 1,
Held = 2,
Dropping = 3,
}
impl Default for WPointKind {
fn default() -> Self {
Self::Holding
}
}
impl FromStr for WPointKind {
type Err = WPointKindParseError;
fn from_str(s: &str) -> Result<WPointKind, WPointKindParseError> {
s.parse::<u32>()
.map_err(WPointKindParseError::ParseIntError)
.and_then(|value| match value {
1 => Ok(WPointKind::Holding),
2 => Ok(WPointKind::Held),
3 => Ok(WPointKind::Dropping),
value => Err(WPointKindParseError::InvalidValue(value)),
})
}
}