use nom::error::ErrorKind; use nom::error::ParseError; use nom::IResult; pub(crate) type Res = IResult; #[derive(Debug)] pub enum CustomError { #[allow(dead_code)] Text(String), Static(&'static str), IO(std::io::Error), Parser(ErrorKind), } impl ParseError for CustomError { fn from_error_kind(_input: I, kind: ErrorKind) -> Self { CustomError::Parser(kind) } fn append(_input: I, _kind: ErrorKind, /*mut*/ other: Self) -> Self { // Doesn't do append like VerboseError other } } impl From for CustomError { fn from(value: std::io::Error) -> Self { CustomError::IO(value) } } impl From<&'static str> for CustomError { fn from(value: &'static str) -> Self { CustomError::Static(value) } }