From 264782d2280a63e82e16dfe005aeee522d102f82 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 16 Mar 2024 15:05:15 +0200 Subject: [PATCH] Various unimportant minor style/doc fixups Signed-off-by: Manos Pitsidianakis --- meli/src/accounts.rs | 3 ++- meli/src/conf.rs | 18 +++++++++--------- melib/src/conf.rs | 4 ++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/meli/src/accounts.rs b/meli/src/accounts.rs index cb8b1837..8add635f 100644 --- a/meli/src/accounts.rs +++ b/meli/src/accounts.rs @@ -830,9 +830,10 @@ impl Account { ret } - pub fn mailboxes_order(&self) -> &Vec { + pub fn mailboxes_order(&self) -> &[MailboxHash] { &self.mailboxes_order } + pub fn name(&self) -> &str { &self.name } diff --git a/meli/src/conf.rs b/meli/src/conf.rs index 4a4734f1..2a1535a3 100644 --- a/meli/src/conf.rs +++ b/meli/src/conf.rs @@ -165,7 +165,7 @@ pub struct FileAccount { pub identity: String, #[serde(default)] pub extra_identities: Vec, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub display_name: Option, #[serde(default = "false_val")] @@ -180,14 +180,18 @@ pub struct FileAccount { pub order: (SortField, SortOrder), #[serde(default = "false_val")] pub manual_refresh: bool, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub refresh_command: Option, #[serde(flatten)] pub conf_override: MailUIConf, #[serde(flatten)] - #[serde(deserialize_with = "extra_settings")] - pub extra: IndexMap, /* use custom deserializer to convert any given value - * (eg bool, number, etc) to string */ + #[serde( + deserialize_with = "extra_settings", + skip_serializing_if = "IndexMap::is_empty" + )] + /// Use custom deserializer to convert any given value (eg `bool`, number, + /// etc) to `String`. + pub extra: IndexMap, } impl FileAccount { @@ -195,10 +199,6 @@ impl FileAccount { &self.mailboxes } - pub fn mailbox(&self) -> &str { - &self.root_mailbox - } - pub fn search_backend(&self) -> &SearchBackend { &self.search_backend } diff --git a/melib/src/conf.rs b/melib/src/conf.rs index ebe15b3f..976a2892 100644 --- a/melib/src/conf.rs +++ b/melib/src/conf.rs @@ -33,6 +33,10 @@ pub use crate::{SortField, SortOrder}; #[derive(Clone, Debug, Default, Serialize)] pub struct AccountSettings { pub name: String, + /// Name of mailbox that is the root of the mailbox hierarchy. + /// + /// Note that this may have special or no meaning depending on the e-mail + /// backend. pub root_mailbox: String, pub format: String, pub identity: String,