diff --git a/Cargo.toml b/Cargo.toml index 45c88d7..966b932 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ is-it-maintained-open-issues = { repository = "async-email/async-smtp" } [dependencies] log = "^0.4" -nom = { version = "^5.0", optional = true } +nom = { version = "^7.0", optional = true } bufstream = { version = "^0.1", optional = true } base64 = { version = "^0.13", optional = true } hostname = { version = "0.3.1", optional = true } diff --git a/src/smtp/client/inner.rs b/src/smtp/client/inner.rs index 20c8b81..8debc55 100644 --- a/src/smtp/client/inner.rs +++ b/src/smtp/client/inner.rs @@ -282,11 +282,11 @@ impl InnerClient { 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)); } } } diff --git a/src/smtp/commands.rs b/src/smtp/commands.rs index 5a0fdb1..f5eefaa 100644 --- a/src/smtp/commands.rs +++ b/src/smtp/commands.rs @@ -11,7 +11,7 @@ use std::convert::AsRef; use std::fmt::{self, Display, Formatter}; /// EHLO command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -34,7 +34,7 @@ impl EhloCommand { } /// STARTTLS command -#[derive(PartialEq, Clone, Debug, Copy)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -48,7 +48,7 @@ impl Display for StarttlsCommand { } /// MAIL command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -80,7 +80,7 @@ impl MailCommand { } /// RCPT command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -111,7 +111,7 @@ impl RcptCommand { } /// DATA command -#[derive(PartialEq, Clone, Debug, Copy)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -125,7 +125,7 @@ impl Display for DataCommand { } /// QUIT command -#[derive(PartialEq, Clone, Debug, Copy)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -139,7 +139,7 @@ impl Display for QuitCommand { } /// NOOP command -#[derive(PartialEq, Clone, Debug, Copy)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -153,7 +153,7 @@ impl Display for NoopCommand { } /// HELP command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -180,7 +180,7 @@ impl HelpCommand { } /// VRFY command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -203,7 +203,7 @@ impl VrfyCommand { } /// EXPN command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -226,7 +226,7 @@ impl ExpnCommand { } /// RSET command -#[derive(PartialEq, Clone, Debug, Copy)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) @@ -240,7 +240,7 @@ impl Display for RsetCommand { } /// AUTH command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr( feature = "serde-impls", derive(serde_derive::Serialize, serde_derive::Deserialize) diff --git a/src/smtp/error.rs b/src/smtp/error.rs index 665d020..ee618bb 100644 --- a/src/smtp/error.rs +++ b/src/smtp/error.rs @@ -62,12 +62,12 @@ pub enum Error { Socks5Error(#[from] fast_socks5::SocksError), } -impl From> for Error { - fn from(err: nom::Err<(&str, nom::error::ErrorKind)>) -> Error { +impl From>> for Error { + fn from(err: nom::Err>) -> 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, }) } } diff --git a/src/smtp/extension.rs b/src/smtp/extension.rs index 51a80c7..c4f18be 100644 --- a/src/smtp/extension.rs +++ b/src/smtp/extension.rs @@ -156,7 +156,7 @@ impl ServerInfo { } let split: Vec<&str> = line.split_whitespace().collect(); - match split.get(0).copied() { + match split.first().copied() { Some("8BITMIME") => { features.insert(Extension::EightBitMime); } diff --git a/src/smtp/response.rs b/src/smtp/response.rs index 1cd4e4d..4989f40 100644 --- a/src/smtp/response.rs +++ b/src/smtp/response.rs @@ -253,7 +253,10 @@ pub(crate) fn parse_response(i: &str) -> IResult<&str, Response> { // Check that all codes are equal. if !lines.iter().all(|&(ref 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. diff --git a/src/smtp/smtp_client.rs b/src/smtp/smtp_client.rs index 0568bad..4513bb6 100644 --- a/src/smtp/smtp_client.rs +++ b/src/smtp/smtp_client.rs @@ -72,7 +72,7 @@ impl Display for ServerAddress { /// Struct holding the configuration for a socks5 proxy connection #[cfg(feature = "socks5")] -#[derive(Default, Clone, Debug, PartialEq)] +#[derive(Default, Clone, Debug, Eq, PartialEq)] pub struct Socks5Config { /// Hostname of the socks5 server pub host: String,