diff --git a/lettre/Cargo.toml b/lettre/Cargo.toml index 8b7c5a3..d79cc0f 100644 --- a/lettre/Cargo.toml +++ b/lettre/Cargo.toml @@ -20,7 +20,7 @@ is-it-maintained-open-issues = { repository = "lettre/lettre" } [dependencies] log = "^0.4" -nom = { version = "^3.2", optional = true } +nom = { version = "^4.0", optional = true } bufstream = { version = "^0.1", optional = true } native-tls = { version = "^0.1", optional = true } base64 = { version = "^0.9", optional = true } diff --git a/lettre/src/smtp/error.rs b/lettre/src/smtp/error.rs index b74d24b..628ed22 100644 --- a/lettre/src/smtp/error.rs +++ b/lettre/src/smtp/error.rs @@ -37,7 +37,7 @@ pub enum Error { /// TLS error Tls(native_tls::Error), /// Parsing error - Parsing(nom::simple_errors::Err), + Parsing(nom::ErrorKind), } impl Display for Error { @@ -77,7 +77,7 @@ impl StdError for Error { Utf8Parsing(ref err) => Some(&*err), Io(ref err) => Some(&*err), Tls(ref err) => Some(&*err), - Parsing(ref err) => Some(&*err), + Parsing(_) => None, _ => None, } } @@ -95,8 +95,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: nom::simple_errors::Err) -> Error { +impl From for Error { + fn from(err: nom::ErrorKind) -> Error { Parsing(err) } } diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index c4299f1..f7a72ec 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -1,8 +1,7 @@ //! SMTP response, containing a mandatory return code and an optional text //! message -use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult}; -use nom::simple_errors::Err as NomError; +use nom::{crlf, ErrorKind as NomErrorKind}; use std::fmt::{Display, Formatter, Result}; use std::result; use std::str::{FromStr, from_utf8}; @@ -126,13 +125,12 @@ pub struct Response { } impl FromStr for Response { - type Err = NomError; + type Err = NomErrorKind; - fn from_str(s: &str) -> result::Result { + fn from_str(s: &str) -> result::Result { match parse_response(s.as_bytes()) { - NomResult::Done(_, res) => Ok(res), - NomResult::Error(e) => Err(e), - NomResult::Incomplete(_) => Err(NomErrorKind::Complete), + Ok((_, res)) => Ok(res), + Err(e) => Err(e.into_error_kind()), } } }