1 | use alloc::string::String; |
2 | |
3 | use core::fmt; |
4 | |
5 | /// An error returned from parsing a triple. |
6 | #[derive (Clone, Debug, PartialEq, Eq)] |
7 | #[allow (missing_docs)] |
8 | pub enum ParseError { |
9 | UnrecognizedArchitecture(String), |
10 | UnrecognizedVendor(String), |
11 | UnrecognizedOperatingSystem(String), |
12 | UnrecognizedEnvironment(String), |
13 | UnrecognizedBinaryFormat(String), |
14 | UnrecognizedField(String), |
15 | } |
16 | |
17 | impl fmt::Display for ParseError { |
18 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
19 | use ParseError::*; |
20 | match self { |
21 | UnrecognizedArchitecture(msg: &String) => write!(fmt, "Unrecognized architecture: {}" , msg), |
22 | UnrecognizedVendor(msg: &String) => write!(fmt, "Unrecognized vendor: {}" , msg), |
23 | UnrecognizedOperatingSystem(msg: &String) => { |
24 | write!(fmt, "Unrecognized operating system: {}" , msg) |
25 | } |
26 | UnrecognizedEnvironment(msg: &String) => write!(fmt, "Unrecognized environment: {}" , msg), |
27 | UnrecognizedBinaryFormat(msg: &String) => write!(fmt, "Unrecognized binary format: {}" , msg), |
28 | UnrecognizedField(msg: &String) => write!(fmt, "Unrecognized field: {}" , msg), |
29 | } |
30 | } |
31 | } |
32 | |
33 | #[cfg (feature = "std" )] |
34 | impl std::error::Error for ParseError {} |
35 | |