From 41d68616e06c740b5f505a4f04b607deb49469bb Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Fri, 28 Aug 2020 11:13:51 +0200 Subject: [PATCH] Remove ClientId::new_domain --- CHANGELOG.md | 2 +- src/transport/smtp/extension.rs | 10 +++------- src/transport/smtp/mod.rs | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ae7b8..de5506a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ Several breaking changes were made between 0.9 and 0.10, but changes should be s * Merge `Email` and `SendableEmail` into `lettre::Email` ([ce37464](https://github.com/lettre/lettre/commit/ce37464)) * When the hostname feature is disabled or hostname cannot be fetched, `127.0.0.1` is used instead of `localhost` as EHLO parameter (for better RFC compliance and mail server compatibility) -* The `new` method of `ClientId` is renamed to `new_domain` +* The `new` method of `ClientId` is deprecated #### Bug Fixes diff --git a/src/transport/smtp/extension.rs b/src/transport/smtp/extension.rs index 4823830..42527e2 100644 --- a/src/transport/smtp/extension.rs +++ b/src/transport/smtp/extension.rs @@ -13,6 +13,7 @@ use std::{ /// Client identifier, the parameter to `EHLO` #[derive(PartialEq, Eq, Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum ClientId { /// A fully-qualified domain name Domain(String), @@ -57,16 +58,11 @@ impl Display for ClientId { } impl ClientId { - #[deprecated(since = "0.10.0", note = "Please use the new_domain function instead")] + #[deprecated(since = "0.10.0", note = "Please use ClientId::Domain(domain) instead")] /// Creates a new `ClientId` from a fully qualified domain name pub fn new(domain: String) -> Self { Self::Domain(domain) } - - /// Creates a new `ClientId` from a fully qualified domain name - pub fn new_domain(domain: String) -> Self { - Self::Domain(domain) - } } /// Supported ESMTP keywords @@ -296,7 +292,7 @@ mod test { #[test] fn test_clientid_fmt() { assert_eq!( - format!("{}", ClientId::new_domain("test".to_string())), + format!("{}", ClientId::Domain("test".to_string())), "test".to_string() ); assert_eq!(format!("{}", LOCALHOST_CLIENT), "[127.0.0.1]".to_string()); diff --git a/src/transport/smtp/mod.rs b/src/transport/smtp/mod.rs index c4d2c76..6e2089b 100644 --- a/src/transport/smtp/mod.rs +++ b/src/transport/smtp/mod.rs @@ -162,7 +162,7 @@ //! # { //! use lettre::transport::smtp::{SMTP_PORT, extension::ClientId, commands::*, client::SmtpConnection}; //! -//! let hello = ClientId::new_domain("my_hostname".to_string()); +//! let hello = ClientId::Domain("my_hostname".to_string()); //! let mut client = SmtpConnection::connect(&("localhost", SMTP_PORT), None, &hello, None).unwrap(); //! client.command( //! Mail::new(Some("user@example.com".parse().unwrap()), vec![])