feat(transport): Implement Copy for Extension

This commit is contained in:
Alexis Mousset
2017-06-18 00:34:30 +02:00
parent 5b2a1be24c
commit b1d2a89b2e
2 changed files with 10 additions and 10 deletions

View File

@@ -38,7 +38,7 @@ impl ClientId {
} }
/// Supported ESMTP keywords /// Supported ESMTP keywords
#[derive(PartialEq, Eq, Hash, Clone, Debug)] #[derive(PartialEq, Eq, Hash, Copy, Clone, Debug)]
pub enum Extension { pub enum Extension {
/// 8BITMIME keyword /// 8BITMIME keyword
/// ///
@@ -144,8 +144,8 @@ impl ServerInfo {
} }
/// Checks if the server supports an ESMTP feature /// Checks if the server supports an ESMTP feature
pub fn supports_feature(&self, keyword: &Extension) -> bool { pub fn supports_feature(&self, keyword: Extension) -> bool {
self.features.contains(keyword) self.features.contains(&keyword)
} }
/// Checks if the server supports an ESMTP feature /// Checks if the server supports an ESMTP feature
@@ -245,8 +245,8 @@ mod test {
assert_eq!(ServerInfo::from_response(&response).unwrap(), server_info); assert_eq!(ServerInfo::from_response(&response).unwrap(), server_info);
assert!(server_info.supports_feature(&Extension::EightBitMime)); assert!(server_info.supports_feature(Extension::EightBitMime));
assert!(!server_info.supports_feature(&Extension::StartTls)); assert!(!server_info.supports_feature(Extension::StartTls));
assert!(!server_info.supports_auth_mechanism(Mechanism::CramMd5)); assert!(!server_info.supports_auth_mechanism(Mechanism::CramMd5));
let response2 = Response::new( let response2 = Response::new(
@@ -279,9 +279,9 @@ mod test {
assert_eq!(ServerInfo::from_response(&response2).unwrap(), server_info2); assert_eq!(ServerInfo::from_response(&response2).unwrap(), server_info2);
assert!(server_info2.supports_feature(&Extension::EightBitMime)); assert!(server_info2.supports_feature(Extension::EightBitMime));
assert!(server_info2.supports_auth_mechanism(Mechanism::Plain)); assert!(server_info2.supports_auth_mechanism(Mechanism::Plain));
assert!(server_info2.supports_auth_mechanism(Mechanism::CramMd5)); assert!(server_info2.supports_auth_mechanism(Mechanism::CramMd5));
assert!(!server_info2.supports_feature(&Extension::StartTls)); assert!(!server_info2.supports_feature(Extension::StartTls));
} }
} }

View File

@@ -424,7 +424,7 @@ impl EmailTransport<SmtpResult> for SmtpTransport {
match ( match (
&self.client_info.security_level, &self.client_info.security_level,
self.server_info.as_ref().unwrap().supports_feature( self.server_info.as_ref().unwrap().supports_feature(
&Extension::StartTls, Extension::StartTls,
), ),
) { ) {
(&SecurityLevel::AlwaysEncrypt, false) => { (&SecurityLevel::AlwaysEncrypt, false) => {
@@ -490,10 +490,10 @@ impl EmailTransport<SmtpResult> for SmtpTransport {
// Mail // Mail
let mail_options = match ( let mail_options = match (
self.server_info.as_ref().unwrap().supports_feature( self.server_info.as_ref().unwrap().supports_feature(
&Extension::EightBitMime, Extension::EightBitMime,
), ),
self.server_info.as_ref().unwrap().supports_feature( self.server_info.as_ref().unwrap().supports_feature(
&Extension::SmtpUtfEight, Extension::SmtpUtfEight,
), ),
) { ) {
(true, true) => Some("BODY=8BITMIME SMTPUTF8"), (true, true) => Some("BODY=8BITMIME SMTPUTF8"),