conf.rs: fix struct decl/impl order in file
Impls and type declarations were out of ordermemfd
parent
7fd511e149
commit
0d198dbb56
96
src/conf.rs
96
src/conf.rs
|
@ -176,41 +176,6 @@ pub struct FileAccount {
|
||||||
pub extra: HashMap<String, String>, /* use custom deserializer to convert any given value (eg bool, number, etc) to string */
|
pub extra: HashMap<String, String>, /* use custom deserializer to convert any given value (eg bool, number, etc) to string */
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FileAccount> for AccountConf {
|
|
||||||
fn from(x: FileAccount) -> Self {
|
|
||||||
let format = x.format.to_lowercase();
|
|
||||||
let root_mailbox = x.root_mailbox.clone();
|
|
||||||
let identity = x.identity.clone();
|
|
||||||
let display_name = x.display_name.clone();
|
|
||||||
let mailboxes = x
|
|
||||||
.mailboxes
|
|
||||||
.iter()
|
|
||||||
.map(|(k, v)| (k.clone(), v.mailbox_conf.clone()))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let acc = AccountSettings {
|
|
||||||
name: String::new(),
|
|
||||||
root_mailbox,
|
|
||||||
format,
|
|
||||||
identity,
|
|
||||||
read_only: x.read_only,
|
|
||||||
display_name,
|
|
||||||
subscribed_mailboxes: x.subscribed_mailboxes.clone(),
|
|
||||||
mailboxes,
|
|
||||||
manual_refresh: x.manual_refresh,
|
|
||||||
extra: x.extra.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mailbox_confs = x.mailboxes.clone();
|
|
||||||
AccountConf {
|
|
||||||
account: acc,
|
|
||||||
conf_override: x.conf_override.clone(),
|
|
||||||
conf: x,
|
|
||||||
mailbox_confs,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FileAccount {
|
impl FileAccount {
|
||||||
pub fn mailboxes(&self) -> &HashMap<String, FileMailboxConf> {
|
pub fn mailboxes(&self) -> &HashMap<String, FileMailboxConf> {
|
||||||
&self.mailboxes
|
&self.mailboxes
|
||||||
|
@ -272,19 +237,39 @@ impl AccountConf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize)]
|
impl From<FileAccount> for AccountConf {
|
||||||
pub struct Settings {
|
fn from(x: FileAccount) -> Self {
|
||||||
pub accounts: HashMap<String, AccountConf>,
|
let format = x.format.to_lowercase();
|
||||||
pub pager: PagerSettings,
|
let root_mailbox = x.root_mailbox.clone();
|
||||||
pub listing: ListingSettings,
|
let identity = x.identity.clone();
|
||||||
pub notifications: NotificationsSettings,
|
let display_name = x.display_name.clone();
|
||||||
pub shortcuts: Shortcuts,
|
let mailboxes = x
|
||||||
pub tags: TagsSettings,
|
.mailboxes
|
||||||
pub composing: ComposingSettings,
|
.iter()
|
||||||
pub pgp: PGPSettings,
|
.map(|(k, v)| (k.clone(), v.mailbox_conf.clone()))
|
||||||
pub terminal: TerminalSettings,
|
.collect();
|
||||||
pub plugins: HashMap<String, Plugin>,
|
|
||||||
pub log: LogSettings,
|
let acc = AccountSettings {
|
||||||
|
name: String::new(),
|
||||||
|
root_mailbox,
|
||||||
|
format,
|
||||||
|
identity,
|
||||||
|
read_only: x.read_only,
|
||||||
|
display_name,
|
||||||
|
subscribed_mailboxes: x.subscribed_mailboxes.clone(),
|
||||||
|
mailboxes,
|
||||||
|
manual_refresh: x.manual_refresh,
|
||||||
|
extra: x.extra.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mailbox_confs = x.mailboxes.clone();
|
||||||
|
AccountConf {
|
||||||
|
account: acc,
|
||||||
|
conf_override: x.conf_override.clone(),
|
||||||
|
conf: x,
|
||||||
|
mailbox_confs,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_file() -> Result<PathBuf> {
|
pub fn get_config_file() -> Result<PathBuf> {
|
||||||
|
@ -444,6 +429,21 @@ impl FileSettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, Serialize)]
|
||||||
|
pub struct Settings {
|
||||||
|
pub accounts: HashMap<String, AccountConf>,
|
||||||
|
pub pager: PagerSettings,
|
||||||
|
pub listing: ListingSettings,
|
||||||
|
pub notifications: NotificationsSettings,
|
||||||
|
pub shortcuts: Shortcuts,
|
||||||
|
pub tags: TagsSettings,
|
||||||
|
pub composing: ComposingSettings,
|
||||||
|
pub pgp: PGPSettings,
|
||||||
|
pub terminal: TerminalSettings,
|
||||||
|
pub plugins: HashMap<String, Plugin>,
|
||||||
|
pub log: LogSettings,
|
||||||
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
pub fn new() -> Result<Settings> {
|
pub fn new() -> Result<Settings> {
|
||||||
let fs = FileSettings::new()?;
|
let fs = FileSettings::new()?;
|
||||||
|
|
Loading…
Reference in New Issue