pub struct Config {
pub accounts: Vec<Account>,
pub defaults: Defaults,
pub trusted_senders: Vec<String>,
pub classify: ClassifyConfig,
pub guardrails: BTreeMap<String, String>,
pub google: Option<GoogleClient>,
}Fields§
§accounts: Vec<Account>§defaults: Defaults§trusted_senders: Vec<String>§classify: ClassifyConfig§guardrails: BTreeMap<String, String>Guardrails: action class -> “allow” | “confirm” | “deny”. Classes: send, delete, cancel, rsvp, bulk, unsubscribe.
google: Option<GoogleClient>The Google OAuth client for Gmail accounts (bring your own, see
docs/gmail.md). PIDGE_GOOGLE_CLIENT_ID / PIDGE_GOOGLE_CLIENT_SECRET
override it.
Implementations§
Source§impl Config
impl Config
Sourcepub const GUARDRAIL_CLASSES: [&'static str; 6]
pub const GUARDRAIL_CLASSES: [&'static str; 6]
Valid guardrail action classes.
Sourcepub const KNOWN_KEYS: &'static [&'static str]
pub const KNOWN_KEYS: &'static [&'static str]
Every settable config key, for pidge config show/help.
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.
Sourcepub fn get_key(&self, key: &str) -> Option<String>
pub fn get_key(&self, key: &str) -> Option<String>
Read a dotted config key as a display string, or None if unset.
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 Forget for Config
impl Freeze for Configwhere
*const u8 is !null: Freeze,
PhantomData<Account>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
impl Move for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Configwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Account>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
impl UnwindSafe for Configwhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
BTreeMap<String, String>: UnwindSafe,
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.