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