#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "lowercase")]
pub enum AuthCredentialsStoreMode {
Keyring,
File,
Auto,
}
impl Default for AuthCredentialsStoreMode {
fn default() -> Self {
#[cfg(target_os = "macos")]
{
Self::File
}
#[cfg(not(target_os = "macos"))]
{
Self::Auto
}
}
}
impl AuthCredentialsStoreMode {
pub fn effective_mode(self) -> Self {
match self {
Self::Auto => {
if super::keyring::is_functional() {
Self::Keyring
} else {
tracing::debug!("Keyring not available, falling back to file storage");
Self::File
}
}
mode => mode,
}
}
}