use std::str::FromStr;
use super::{Field, FieldError};
#[derive(Debug, PartialEq)]
pub enum Source<const I: usize> {
GovernmentSources,
OtherSources,
BearingInTrue,
}
impl<const I: usize> Field for Source<I> {}
impl<const I: usize> FromStr for Source<I> {
type Err = FieldError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match &s[I..I + 1] {
"Y" => Ok(Self::GovernmentSources),
"N" | " " => Ok(Self::OtherSources),
"T" => Ok(Self::BearingInTrue),
_ => Err(FieldError::UnexpectedChar("unexpected source identifier")),
}
}
}