#[derive(Debug)]
pub enum StatMParseError
{
CouldNotOpenFile(io::Error),
MissingField
{
index: NonZeroU8,
name: &'static str,
},
ParseNumber
{
index: NonZeroU8,
name: &'static str,
cause: ParseNumberError,
},
FieldWasNotZero
{
index: NonZeroU8,
name: &'static str,
},
}
impl Display for StatMParseError
{
#[inline(always)]
fn fmt(&self, f: &mut Formatter) -> fmt::Result
{
Debug::fmt(self, f)
}
}
impl error::Error for StatMParseError
{
#[inline(always)]
fn source(&self) -> Option<&(dyn error::Error + 'static)>
{
use self::StatMParseError::*;
match self
{
&CouldNotOpenFile(ref cause) => Some(cause),
&MissingField { .. } => None,
&ParseNumber { ref cause, .. } => Some(cause),
&FieldWasNotZero { .. } => None,
}
}
}
impl From<io::Error> for StatMParseError
{
#[inline(always)]
fn from(error: io::Error) -> Self
{
StatMParseError::CouldNotOpenFile(error)
}
}