1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::io;
use std::num;

/// Enumeration of different errors that can occur during parsing
#[derive(Debug)]
pub enum ParseError {
    IOError(io::Error),
    Utf8Error(std::str::Utf8Error),
    SyntaxError,
    NonASCIICharacters,
    NumberOutOfRange,
    BadExtension,
    MissingExtension,
}

impl From<num::ParseIntError> for ParseError {
    fn from(_: num::ParseIntError) -> Self {
        ParseError::SyntaxError
    }
}

impl From<std::str::Utf8Error> for ParseError {
    fn from(e: std::str::Utf8Error) -> Self {
        ParseError::Utf8Error(e)
    }
}