Upgrade to nom 6

This commit is contained in:
Paolo Barbolini
2020-11-02 09:43:35 +01:00
committed by Alexis Mousset
parent 6216fd92c8
commit b187885e70
5 changed files with 13 additions and 10 deletions

View File

@@ -36,7 +36,7 @@ serde = { version = "1", optional = true, features = ["derive"] }
serde_json = { version = "1", optional = true }
# smtp
nom = { version = "5", optional = true }
nom = { version = "6", default-features = false, features = ["alloc"], optional = true }
r2d2 = { version = "0.8", optional = true } # feature
hostname = { version = "0.3", optional = true } # feature

View File

@@ -268,11 +268,11 @@ impl AsyncSmtpConnection {
return Err(response.into());
}
Err(nom::Err::Failure(e)) => {
return Err(Error::Parsing(e.1));
return Err(Error::Parsing(e.code));
}
Err(nom::Err::Incomplete(_)) => { /* read more */ }
Err(nom::Err::Error(e)) => {
return Err(Error::Parsing(e.1));
return Err(Error::Parsing(e.code));
}
}
}

View File

@@ -253,11 +253,11 @@ impl SmtpConnection {
return Err(response.into());
}
Err(nom::Err::Failure(e)) => {
return Err(Error::Parsing(e.1));
return Err(Error::Parsing(e.code));
}
Err(nom::Err::Incomplete(_)) => { /* read more */ }
Err(nom::Err::Error(e)) => {
return Err(Error::Parsing(e.1));
return Err(Error::Parsing(e.code));
}
}
}

View File

@@ -109,12 +109,12 @@ impl From<native_tls::Error> for Error {
}
}
impl From<nom::Err<(&str, nom::error::ErrorKind)>> for Error {
fn from(err: nom::Err<(&str, nom::error::ErrorKind)>) -> Error {
impl From<nom::Err<nom::error::Error<&str>>> for Error {
fn from(err: nom::Err<nom::error::Error<&str>>) -> Error {
Parsing(match err {
nom::Err::Incomplete(_) => nom::error::ErrorKind::Complete,
nom::Err::Failure((_, k)) => k,
nom::Err::Error((_, k)) => k,
nom::Err::Failure(e) => e.code,
nom::Err::Error(e) => e.code,
})
}
}

View File

@@ -238,7 +238,10 @@ pub(crate) fn parse_response(i: &str) -> IResult<&str, Response> {
// Check that all codes are equal.
if !lines.iter().all(|&(code, _, _)| code == last_code) {
return Err(nom::Err::Failure(("", nom::error::ErrorKind::Not)));
return Err(nom::Err::Failure(nom::error::Error::new(
"",
nom::error::ErrorKind::Not,
)));
}
// Extract text from lines, and append last line.