#[allow(unused_imports)]
use crate::nostd_prelude::*;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum EncodeError {
#[error("CBOR serialization failed: {0}")]
Serialization(String),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum DecodeError {
#[error("CBOR deserialization failed: {0}")]
Deserialization(String),
#[error("expected CBOR tag {expected}, found {found}")]
UnexpectedTag {
expected: u64,
found: u64,
},
#[error("invalid structure: {0}")]
InvalidStructure(String),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum BuilderError {
#[error("missing required field: {0}")]
MissingField(&'static str),
#[error("triples map is empty — at least one triple type must be populated")]
EmptyTriples,
#[error("at least one CoMID tag is required")]
NoTags,
#[error("CDDL requires [+ {field}] but the list is empty")]
EmptyList {
field: &'static str,
},
#[error("invalid validity: not_before must be <= not_after")]
InvalidValidity,
#[error("validation error: {0}")]
Validation(String),
#[error("encoding error: {0}")]
Encode(#[from] EncodeError),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ValidationError {
#[error("decode error: {0}")]
Decode(#[from] DecodeError),
#[error("CoRIM has expired (not-after is in the past)")]
Expired,
#[error("CoRIM is not yet valid (not-before is in the future)")]
NotYetValid,
#[error("no CoMID tags found in the CoRIM")]
NoComidTags,
#[error("CoMID tag-identity is missing tag-id")]
MissingTagId,
#[error("CoMID triples map is empty")]
EmptyTriples,
#[error("CoTL tags-list is empty")]
EmptyTagsList,
#[error("{0}")]
Invalid(String),
#[error("non-empty constraint violated: {0}")]
NonEmpty(String),
#[error("no common digest algorithms between reference and evidence")]
NoCommonAlgorithms,
#[error("digest mismatch for algorithm {alg}")]
DigestMismatch {
alg: i64,
},
#[error("SVN mismatch: expected {expected}, got {actual}")]
SvnMismatch {
expected: u64,
actual: u64,
},
#[error("conditional-endorsement-series entries use inconsistent mkeys")]
InconsistentMkeys,
#[error("system clock error: {0}")]
Clock(String),
#[error("input payload too large: {size} bytes (max {max})")]
PayloadTooLarge {
size: usize,
max: usize,
},
}