pub mod cipher;
pub mod signer;
use google_cloud_kms_v1::model::crypto_key_version::CryptoKeyVersionAlgorithm;
use snafu::prelude::*;
use super::version::VersionResolutionError;
#[derive(Debug, Snafu)]
#[snafu(module(setup))]
#[non_exhaustive]
pub enum SetupError {
GetCryptoKeyVersion {
source: google_cloud_kms_v1::Error,
},
#[snafu(display("unsupported algorithm {algorithm:?}"))]
UnsupportedAlgorithm {
algorithm: CryptoKeyVersionAlgorithm,
},
}
impl SetupError {
#[must_use]
pub fn is_retryable(&self) -> bool {
match self {
SetupError::GetCryptoKeyVersion { source } => {
source.is_timeout() || source.is_exhausted()
}
SetupError::UnsupportedAlgorithm { .. } => false,
}
}
}
#[derive(Debug, Snafu)]
#[non_exhaustive]
pub enum KeyError {
ResolveVersion {
source: VersionResolutionError,
},
GetCryptoKeyVersion {
source: google_cloud_kms_v1::Error,
},
#[snafu(display("unsupported algorithm {algorithm:?}"))]
UnsupportedAlgorithm {
algorithm: CryptoKeyVersionAlgorithm,
},
ListCryptoKeyVersions {
source: google_cloud_kms_v1::Error,
},
NoEnabledCryptoKeyVersions,
}
impl KeyError {
#[must_use]
pub fn is_retryable(&self) -> bool {
match self {
KeyError::ResolveVersion { source } => source.is_retryable(),
KeyError::GetCryptoKeyVersion { source }
| KeyError::ListCryptoKeyVersions { source } => {
source.is_timeout() || source.is_exhausted()
}
KeyError::UnsupportedAlgorithm { .. } | KeyError::NoEnabledCryptoKeyVersions => false,
}
}
}