use secrecy::SecretString;
#[derive(Clone, Default)]
pub enum Auth {
ApiKey(SecretString),
BearerToken(SecretString),
#[default]
None,
}
impl Auth {
pub fn secret(&self) -> Option<&SecretString> {
match self {
Auth::ApiKey(s) | Auth::BearerToken(s) => Some(s),
Auth::None => None,
}
}
pub fn is_some(&self) -> bool {
!matches!(self, Auth::None)
}
}
impl std::fmt::Debug for Auth {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Auth::ApiKey(_) => f.write_str("Auth::ApiKey(***)"),
Auth::BearerToken(_) => f.write_str("Auth::BearerToken(***)"),
Auth::None => f.write_str("Auth::None"),
}
}
}