Issues with nom 6 error type
This commit is contained in:
@@ -10,3 +10,4 @@ http = "0.2"
|
||||
serde_json = "1.0"
|
||||
async-channel = "1.6"
|
||||
chrono = { version = "0.4.19", features = ["serde"] }
|
||||
nom = "6.1.2"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use nom::error::ErrorKind;
|
||||
use std::fmt::Debug;
|
||||
use std::num::ParseIntError;
|
||||
use std::string::FromUtf8Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
@@ -17,6 +20,12 @@ impl From<String> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Error {
|
||||
fn from(k: &str) -> Self {
|
||||
Self { msg: k.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(fmt, "Error")
|
||||
@@ -66,3 +75,35 @@ impl From<ParseIntError> for Error {
|
||||
Self { msg: k.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FromUtf8Error> for Error {
|
||||
fn from(k: FromUtf8Error) -> Self {
|
||||
Self { msg: k.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<nom::Err<T>> for Error {
|
||||
fn from(k: nom::Err<T>) -> Self {
|
||||
Self {
|
||||
msg: format!("nom::Err<T>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> From<nom::error::VerboseError<I>> for Error {
|
||||
fn from(k: nom::error::VerboseError<I>) -> Self {
|
||||
Self {
|
||||
msg: format!("nom::error::VerboseError<I>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> nom::error::ParseError<I> for Error {
|
||||
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn append(input: I, kind: ErrorKind, other: Self) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user