pub struct Config {
pub accounts: Vec<Account>,
pub defaults: Defaults,
pub trusted_senders: Vec<String>,
}Fields§
§accounts: Vec<Account>§defaults: Defaults§trusted_senders: Vec<String>Implementations§
Source§impl Config
impl Config
Sourcepub fn default_path() -> Result<PathBuf, CoreError>
pub fn default_path() -> Result<PathBuf, CoreError>
Default path: ${XDG_CONFIG_HOME:-~/.config}/pidge/config.yaml.
Sourcepub fn load() -> Result<Self, CoreError>
pub fn load() -> Result<Self, CoreError>
Load the config from the default path. If the file doesn’t exist, returns Config::default().
Sourcepub fn load_from(path: &Path) -> Result<Self, CoreError>
pub fn load_from(path: &Path) -> Result<Self, CoreError>
Load from a specific path. Useful for tests.
Sourcepub fn save_to(&self, path: &Path) -> Result<(), CoreError>
pub fn save_to(&self, path: &Path) -> Result<(), CoreError>
Save to a specific path. Useful for tests.
Sourcepub fn add_account(&mut self, account: Account)
pub fn add_account(&mut self, account: Account)
Add or replace an account by email. If this is the first account, also sets it as the default send AND default calendar account.
Sourcepub fn remove_account(&mut self, email: &str) -> Option<Account>
pub fn remove_account(&mut self, email: &str) -> Option<Account>
Remove an account by email. Returns the removed account. If the removed account was a default, that default is cleared.
Sourcepub fn set_default_send(&mut self, email: &str) -> Result<(), CoreError>
pub fn set_default_send(&mut self, email: &str) -> Result<(), CoreError>
Set the default send account. Errors if the email isn’t a known signed-in account.
Sourcepub fn set_default_calendar(&mut self, email: &str) -> Result<(), CoreError>
pub fn set_default_calendar(&mut self, email: &str) -> Result<(), CoreError>
Set the default calendar account. Errors if the email isn’t a known signed-in account.
Sourcepub fn add_trusted_sender(&mut self, email: &str)
pub fn add_trusted_sender(&mut self, email: &str)
Add an email to the trusted-senders list (case-insensitive). Idempotent.
Sourcepub fn remove_trusted_sender(&mut self, email: &str) -> bool
pub fn remove_trusted_sender(&mut self, email: &str) -> bool
Remove an email from the trusted-senders list (case-insensitive). Returns true if it was present, false if it wasn’t (idempotent either way).
Sourcepub fn is_sender_trusted(&self, email: &str) -> bool
pub fn is_sender_trusted(&self, email: &str) -> bool
Case-insensitive check for whether an email is in the trusted-senders list.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.