diff --git a/lettre/src/file/mod.rs b/lettre/src/file/mod.rs index 34596db..fcb80f6 100644 --- a/lettre/src/file/mod.rs +++ b/lettre/src/file/mod.rs @@ -17,6 +17,7 @@ pub mod error; /// Writes the content and the envelope information to a file #[derive(Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct FileEmailTransport { path: PathBuf, } diff --git a/lettre/src/sendmail/mod.rs b/lettre/src/sendmail/mod.rs index e9986c0..a40d9d6 100644 --- a/lettre/src/sendmail/mod.rs +++ b/lettre/src/sendmail/mod.rs @@ -11,6 +11,7 @@ pub mod error; /// Sends an email using the `sendmail` command #[derive(Debug, Default)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct SendmailTransport { command: String, } diff --git a/lettre/src/smtp/authentication.rs b/lettre/src/smtp/authentication.rs index 7d8886d..ae50f43 100644 --- a/lettre/src/smtp/authentication.rs +++ b/lettre/src/smtp/authentication.rs @@ -51,6 +51,7 @@ impl, T: Into> IntoCredentials for (S, T) { /// Contains user credentials #[derive(PartialEq, Eq, Clone, Hash, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct Credentials { username: String, password: String, @@ -65,6 +66,7 @@ impl Credentials { /// Represents authentication mechanisms #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum Mechanism { /// PLAIN authentication mechanism /// RFC 4616: https://tools.ietf.org/html/rfc4616 diff --git a/lettre/src/smtp/client/mod.rs b/lettre/src/smtp/client/mod.rs index 944c976..32c090f 100644 --- a/lettre/src/smtp/client/mod.rs +++ b/lettre/src/smtp/client/mod.rs @@ -19,6 +19,7 @@ pub mod mock; /// The codec used for transparency #[derive(Default, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct ClientCodec { escape_count: u8, } diff --git a/lettre/src/smtp/commands.rs b/lettre/src/smtp/commands.rs index e8ea924..8fa4e9a 100644 --- a/lettre/src/smtp/commands.rs +++ b/lettre/src/smtp/commands.rs @@ -12,6 +12,7 @@ use std::fmt::{self, Display, Formatter}; /// EHLO command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct EhloCommand { client_id: ClientId, } @@ -32,6 +33,7 @@ impl EhloCommand { /// STARTTLS command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct StarttlsCommand; impl Display for StarttlsCommand { @@ -43,6 +45,7 @@ impl Display for StarttlsCommand { /// MAIL command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct MailCommand { sender: Option, parameters: Vec, @@ -74,6 +77,7 @@ impl MailCommand { /// RCPT command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct RcptCommand { recipient: EmailAddress, parameters: Vec, @@ -101,6 +105,7 @@ impl RcptCommand { /// DATA command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct DataCommand; impl Display for DataCommand { @@ -112,6 +117,7 @@ impl Display for DataCommand { /// QUIT command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct QuitCommand; impl Display for QuitCommand { @@ -123,6 +129,7 @@ impl Display for QuitCommand { /// NOOP command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct NoopCommand; impl Display for NoopCommand { @@ -134,6 +141,7 @@ impl Display for NoopCommand { /// HELP command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct HelpCommand { argument: Option, } @@ -157,6 +165,7 @@ impl HelpCommand { /// VRFY command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct VrfyCommand { argument: String, } @@ -177,6 +186,7 @@ impl VrfyCommand { /// EXPN command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct ExpnCommand { argument: String, } @@ -197,6 +207,7 @@ impl ExpnCommand { /// RSET command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct RsetCommand; impl Display for RsetCommand { @@ -208,6 +219,7 @@ impl Display for RsetCommand { /// AUTH command #[derive(PartialEq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct AuthCommand { mechanism: Mechanism, credentials: Credentials, diff --git a/lettre/src/smtp/extension.rs b/lettre/src/smtp/extension.rs index 3a06d8f..c5d02d0 100644 --- a/lettre/src/smtp/extension.rs +++ b/lettre/src/smtp/extension.rs @@ -15,6 +15,7 @@ pub const DEFAULT_EHLO_HOSTNAME: &str = "localhost"; /// Client identifier, the parameter to `EHLO` #[derive(PartialEq, Eq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum ClientId { /// A fully-qualified domain name Domain(String), @@ -52,6 +53,7 @@ impl ClientId { /// Supported ESMTP keywords #[derive(PartialEq, Eq, Hash, Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum Extension { /// 8BITMIME keyword /// @@ -82,6 +84,7 @@ impl Display for Extension { /// Contains information about an SMTP server #[derive(Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct ServerInfo { /// Server name /// @@ -173,6 +176,7 @@ impl ServerInfo { /// A `MAIL FROM` extension parameter #[derive(PartialEq, Eq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum MailParameter { /// `BODY` parameter Body(MailBodyParameter), @@ -209,6 +213,7 @@ impl Display for MailParameter { /// Values for the `BODY` parameter to `MAIL FROM` #[derive(PartialEq, Eq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum MailBodyParameter { /// `7BIT` SevenBit, @@ -227,6 +232,7 @@ impl Display for MailBodyParameter { /// A `RCPT TO` extension parameter #[derive(PartialEq, Eq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum RcptParameter { /// Custom parameter Other { diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index 8f8856f..824f315 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -80,6 +80,7 @@ pub enum ClientSecurity { /// Configures connection reuse behavior #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum ConnectionReuseParameters { /// Unlimitied connection reuse ReuseUnlimited, diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index 3bd2611..e574854 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -10,6 +10,7 @@ use std::str::{FromStr, from_utf8}; /// First digit indicates severity #[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum Severity { /// 2yx PositiveCompletion = 2, @@ -29,6 +30,7 @@ impl Display for Severity { /// Second digit #[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum Category { /// x0z Syntax = 0, @@ -52,6 +54,7 @@ impl Display for Category { /// The detail digit of a response code (third digit) #[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum Detail { #[allow(missing_docs)] Zero = 0, @@ -83,6 +86,7 @@ impl Display for Detail { /// Represents a 3 digit SMTP response code #[derive(PartialEq, Eq, Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct Code { /// First digit of the response code pub severity: Severity, @@ -113,6 +117,7 @@ impl Code { /// /// The text message is optional, only the code is mandatory #[derive(PartialEq, Eq, Clone, Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct Response { /// Response code pub code: Code, diff --git a/lettre/src/smtp/util.rs b/lettre/src/smtp/util.rs index 06e5593..6c5c822 100644 --- a/lettre/src/smtp/util.rs +++ b/lettre/src/smtp/util.rs @@ -4,6 +4,7 @@ use std::fmt::{Display, Formatter, Result as FmtResult}; /// Encode a string as xtext #[derive(Debug)] +#[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct XText<'a>(pub &'a str); impl<'a> Display for XText<'a> {