From 8bb97e62ca9cec9c7b09025ade05267ce8f4a263 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Thu, 20 Sep 2018 20:09:06 +0200 Subject: [PATCH] Update nom to 0.4 --- lettre/Cargo.toml | 2 +- lettre/src/smtp/error.rs | 7 +++---- lettre/src/smtp/response.rs | 12 +++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lettre/Cargo.toml b/lettre/Cargo.toml index 8bf714a..47c0c25 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.2", optional = true } base64 = { version = "^0.9", optional = true } diff --git a/lettre/src/smtp/error.rs b/lettre/src/smtp/error.rs index 1866bd0..01c60f5 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,6 @@ impl StdError for Error { Utf8Parsing(ref err) => Some(&*err), Io(ref err) => Some(&*err), Tls(ref err) => Some(&*err), - Parsing(ref err) => Some(&*err), _ => None, } } @@ -95,8 +94,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 a935b06..821b46c 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::simple_errors::Err as NomError; -use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult}; +use nom::{crlf, ErrorKind as NomErrorKind}; use std::fmt::{Display, Formatter, Result}; use std::result; use std::str::{from_utf8, FromStr}; @@ -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()), } } }