#[derive(Debug, thiserror::Error)]
pub enum MlsProviderError {
#[error(transparent)]
KeystoreError(#[from] core_crypto_keystore::CryptoKeystoreError),
#[error("The provided entropy seed has an incorrect length: expected {expected}, found {actual}")]
EntropySeedLengthError { actual: usize, expected: usize },
#[error("CSPRNG lock is poisoned")]
RngLockPoison,
#[error("Unable to collect enough randomness.")]
UnsufficientEntropy,
#[error("An error occured while generating a X509 certificate")]
CertificateGenerationError,
#[error("This ciphersuite isn't supported as of now")]
UnsupportedSignatureScheme,
#[error(transparent)]
SignatureError(#[from] signature::Error),
#[error("{0}")]
StringError(String),
}
#[allow(clippy::from_over_into)]
impl Into<String> for MlsProviderError {
fn into(self) -> String {
self.to_string()
}
}
impl Clone for MlsProviderError {
fn clone(&self) -> Self {
Self::StringError(self.to_string())
}
}
impl PartialEq for MlsProviderError {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(
MlsProviderError::EntropySeedLengthError { expected, actual },
MlsProviderError::EntropySeedLengthError {
expected: expected2,
actual: actual2,
},
) => expected == expected2 && actual == actual2,
(MlsProviderError::StringError(s), MlsProviderError::StringError(s2)) => s == s2,
(MlsProviderError::RngLockPoison, MlsProviderError::RngLockPoison) => true,
(MlsProviderError::UnsufficientEntropy, MlsProviderError::UnsufficientEntropy) => true,
(MlsProviderError::CertificateGenerationError, MlsProviderError::CertificateGenerationError) => true,
(MlsProviderError::UnsupportedSignatureScheme, MlsProviderError::UnsupportedSignatureScheme) => true,
_ => false,
}
}
}
pub type MlsProviderResult<T> = Result<T, MlsProviderError>;