Browse Source

melib/smtp: add serde field default values

tags/alpha-0.6.0
Manos Pitsidianakis 1 year ago
parent
commit
d8f2a08e7b
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 8
      melib/src/conf.rs
  2. 11
      melib/src/smtp.rs

8
melib/src/conf.rs

@ -107,11 +107,15 @@ impl MailboxConf {
}
}
pub(in crate::conf) fn false_val() -> bool {
pub fn true_val() -> bool {
true
}
pub fn false_val() -> bool {
false
}
pub(in crate::conf) fn none<T>() -> Option<T> {
pub fn none<T>() -> Option<T> {
None
}

11
melib/src/smtp.rs

@ -173,22 +173,33 @@ pub struct SmtpServerConf {
/// Configured SMTP extensions to use
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SmtpExtensionSupport {
#[serde(default = "crate::conf::true_val")]
pipelining: bool,
#[serde(default = "crate::conf::true_val")]
chunking: bool,
//Essentially, the PRDR extension to SMTP allows (but does not require) an SMTP server to
//issue multiple responses after a message has been transferred, by mutual consent of the
//client and server. SMTP clients that support the PRDR extension then use the expanded
//responses as supplemental data to the responses that were received during the earlier
//envelope exchange.
#[serde(default = "crate::conf::true_val")]
prdr: bool,
#[serde(default = "crate::conf::false_val")]
binarymime: bool,
//Resources:
//- http://www.postfix.org/SMTPUTF8_README.html
#[serde(default = "crate::conf::true_val")]
smtputf8: bool,
#[serde(default = "crate::conf::true_val")]
auth: bool,
#[serde(default = "default_dsn")]
dsn_notify: Option<Cow<'static, str>>,
}
fn default_dsn() -> Option<Cow<'static, str>> {
Some("FAILURE".into())
}
impl Default for SmtpExtensionSupport {
fn default() -> Self {
Self {

Loading…
Cancel
Save