use evault_core::error::SecretError;
pub const fn is_not_found(e: &keyring_core::Error) -> bool {
matches!(e, keyring_core::Error::NoEntry)
}
pub fn map(e: keyring_core::Error) -> SecretError {
use keyring_core::Error;
match e {
Error::NoStorageAccess(_) => SecretError::Unavailable,
Error::NoEntry => SecretError::Backend("no_entry_unfiltered".into()),
other => SecretError::Backend(label(&other).into()),
}
}
const fn label(e: &keyring_core::Error) -> &'static str {
use keyring_core::Error;
match e {
Error::NoEntry => "no_entry",
Error::NoStorageAccess(_) => "no_storage_access",
Error::Ambiguous(_) => "ambiguous",
Error::Invalid(_, _) => "invalid",
Error::PlatformFailure(_) => "platform_failure",
Error::BadEncoding(_) => "bad_encoding",
Error::TooLong(_, _) => "too_long",
Error::BadDataFormat(_, _) => "bad_data_format",
Error::BadStoreFormat(_) => "bad_store_format",
Error::NoDefaultStore => "no_default_store",
Error::NotSupportedByStore(_) => "not_supported_by_store",
_ => "other",
}
}