#[derive(Debug)]
pub struct CredentialError {
#[expect(
dead_code,
reason = "This is deliberately unused: The kind is merely a debug helper, and when no logging is active, code should not behave any different no matter in which way the credential processing failed"
)]
detail: CredentialErrorDetail,
pub(crate) position: Option<usize>,
}
#[derive(Debug, Copy, Clone)]
#[non_exhaustive]
pub enum CredentialErrorDetail {
ProtocolViolation,
UnsupportedExtension,
UnsupportedAlgorithm,
ConstraintExceeded,
InconsistentDetails,
KeyNotPresent,
VerifyFailed,
}
impl From<CredentialErrorDetail> for CredentialError {
fn from(value: CredentialErrorDetail) -> Self {
Self {
detail: value,
position: None,
}
}
}
impl From<minicbor::decode::Error> for CredentialError {
fn from(_: minicbor::decode::Error) -> Self {
Self {
detail: CredentialErrorDetail::UnsupportedExtension,
position: None,
}
}
}
impl From<minicbor::encode::Error<heapless::CapacityError>> for CredentialError {
fn from(_: minicbor::encode::Error<heapless::CapacityError>) -> Self {
Self {
detail: CredentialErrorDetail::ConstraintExceeded,
position: None,
}
}
}