melib/smtp: add serde field default values

memfd
Manos Pitsidianakis 2020-07-27 15:03:03 +03:00
parent 8ec0da4fbd
commit d8f2a08e7b
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 17 additions and 2 deletions

View File

@ -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
}

View File

@ -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 {