pub struct ProviderConfig {
pub sections: Vec<ProviderSection>,
pub path_override: Option<PathBuf>,
}Expand description
Parsed provider configuration from ~/.purple/providers.
Fields§
§sections: Vec<ProviderSection>§path_override: Option<PathBuf>Override path for save(). None uses the default ~/.purple/providers. Set to Some in tests to avoid writing to the real config.
Implementations§
Source§impl ProviderConfig
impl ProviderConfig
Sourcepub fn load() -> Self
pub fn load() -> Self
Load provider config from ~/.purple/providers. Returns empty config if file doesn’t exist (normal first-use). Prints a warning to stderr on real IO errors (permissions, etc.).
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save provider config to ~/.purple/providers (atomic write, chmod 600). Respects path_override when set (used in tests).
Sourcepub fn section(&self, provider: &str) -> Option<&ProviderSection>
pub fn section(&self, provider: &str) -> Option<&ProviderSection>
Get the first section matching the given provider name.
For multi-config use, prefer section_by_id or sections_for_provider.
Sourcepub fn sections_for_provider(&self, provider: &str) -> Vec<&ProviderSection>
pub fn sections_for_provider(&self, provider: &str) -> Vec<&ProviderSection>
Get all sections for a given provider name (multi-config support).
Sourcepub fn section_by_id(&self, id: &ProviderConfigId) -> Option<&ProviderSection>
pub fn section_by_id(&self, id: &ProviderConfigId) -> Option<&ProviderSection>
Get a section by exact ProviderConfigId match.
Sourcepub fn set_section(&mut self, section: ProviderSection)
pub fn set_section(&mut self, section: ProviderSection)
Add or replace a provider section. Matches on full ProviderConfigId so labeled configs are independent from each other and from a bare config.
Sourcepub fn remove_section(&mut self, provider: &str)
pub fn remove_section(&mut self, provider: &str)
Remove all sections matching the given provider name (any label).
Sourcepub fn remove_section_by_id(&mut self, id: &ProviderConfigId)
pub fn remove_section_by_id(&mut self, id: &ProviderConfigId)
Remove the section with the exact ProviderConfigId.
Sourcepub fn configured_providers(&self) -> &[ProviderSection]
pub fn configured_providers(&self) -> &[ProviderSection]
Get all configured provider sections.
Trait Implementations§
Source§impl Clone for ProviderConfig
impl Clone for ProviderConfig
Source§fn clone(&self) -> ProviderConfig
fn clone(&self) -> ProviderConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProviderConfig
impl Debug for ProviderConfig
Source§impl Default for ProviderConfig
impl Default for ProviderConfig
Source§fn default() -> ProviderConfig
fn default() -> ProviderConfig
Auto Trait Implementations§
impl Freeze for ProviderConfig
impl RefUnwindSafe for ProviderConfig
impl Send for ProviderConfig
impl Sync for ProviderConfig
impl Unpin for ProviderConfig
impl UnsafeUnpin for ProviderConfig
impl UnwindSafe for ProviderConfig
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more