pub struct AuthPool {
pub pool: HashMap<String, Credential>,
pub defaults: HashMap<String, String>,
pub order: HashMap<String, Vec<String>>,
pub usage_stats: HashMap<String, UsageStats>,
}Expand description
The complete auth pool (serialized to TOML).
Fields§
§pool: HashMap<String, Credential>§defaults: HashMap<String, String>§order: HashMap<String, Vec<String>>§usage_stats: HashMap<String, UsageStats>Implementations§
Source§impl AuthPool
impl AuthPool
Sourcepub fn add(&mut self, name: &str, credential: Credential)
pub fn add(&mut self, name: &str, credential: Credential)
Add a credential to the pool.
Sourcepub fn get(&self, name: &str) -> Option<&Credential>
pub fn get(&self, name: &str) -> Option<&Credential>
Get a credential by name.
Sourcepub fn get_default(&self, provider: &str) -> Option<(&str, &Credential)>
pub fn get_default(&self, provider: &str) -> Option<(&str, &Credential)>
Get the default credential for a provider.
Sourcepub fn set_default(&mut self, name: &str) -> Result<()>
pub fn set_default(&mut self, name: &str) -> Result<()>
Set a credential as the default for its provider.
Sourcepub fn credentials_for_provider(
&self,
provider: &str,
) -> Vec<(&str, &Credential)>
pub fn credentials_for_provider( &self, provider: &str, ) -> Vec<(&str, &Credential)>
Get all credentials for a provider, in order.
Sourcepub fn all_credentials(&self) -> Vec<(&str, &Credential)>
pub fn all_credentials(&self) -> Vec<(&str, &Credential)>
List all credentials sorted by name.
Sourcepub fn next_credential(
&self,
provider: &str,
failed_name: &str,
) -> Option<(&str, &Credential)>
pub fn next_credential( &self, provider: &str, failed_name: &str, ) -> Option<(&str, &Credential)>
Get the next credential to try for a provider after a failure.
Rotates through the order list, skipping credentials in cooldown.
Sourcepub fn record_usage(&mut self, name: &str, success: bool)
pub fn record_usage(&mut self, name: &str, success: bool)
Record a usage event for a credential.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AuthPool
impl<'de> Deserialize<'de> for AuthPool
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for AuthPool
impl RefUnwindSafe for AuthPool
impl Send for AuthPool
impl Sync for AuthPool
impl Unpin for AuthPool
impl UnsafeUnpin for AuthPool
impl UnwindSafe for AuthPool
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
Mutably borrows from an owned value. Read more