Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions src/smtp/client/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ impl<S: Connector + Write + Read + Unpin> InnerClient<S> {
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));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/smtp/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/smtp/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ pub enum Error {
Socks5Error(#[from] fast_socks5::SocksError),
}

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,
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/smtp/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down