use crate::batch_stream::HomologicalStreamPortableError;
use crate::ext::ExtError;
#[derive(Clone, Debug)]
pub enum SelfExtLocusArtifactError {
ParseLimit {
path: String,
used: usize,
limit: usize,
},
Syntax { byte: usize, message: String },
Schema { found: String },
Kind { found: String },
NonCanonical,
FingerprintShape,
FingerprintMismatch,
Checkpoint(HomologicalStreamPortableError),
CheckpointNotComplete,
DegreeRange { first: usize, last: usize },
DegreeOutsideCheckpoint { degree: usize, checkpoint: usize },
RepresentativeIndex { index: usize },
VerificationLimit {
field: &'static str,
declared: usize,
limit: usize,
},
CounterOverflow { field: &'static str },
Ext(ExtError),
LocusMismatch { representative: usize },
}
display_error! { SelfExtLocusArtifactError {
Self::ParseLimit { path, used, limit } => "theorem artifact field {path} needs {used} units, limit {limit}";
Self::Syntax { byte, message } => "invalid theorem artifact JSON at byte {byte}: {message}";
Self::Schema { found } => "unsupported theorem artifact schema {found:?}";
Self::Kind { found } => "unsupported theorem artifact kind {found:?}";
Self::NonCanonical => "theorem artifact JSON is not canonical";
Self::FingerprintShape => "theorem artifact fingerprint must contain 16 lowercase hexadecimal digits";
Self::FingerprintMismatch => "theorem artifact fingerprint does not match its canonical fields";
Self::Checkpoint(error) => "embedded homological checkpoint rejected: {error}";
Self::CheckpointNotComplete => "self-Ext locus needs a complete homological checkpoint";
Self::DegreeRange { first, last } => "self-Ext degree range {first} through {last} must start above zero and be nonempty";
Self::DegreeOutsideCheckpoint { degree, checkpoint } => "self-Ext degree {degree} exceeds checkpoint degree {checkpoint}";
Self::RepresentativeIndex { index } => "self-Ext locus index {index} is unordered, repeated, or outside the census";
Self::VerificationLimit { field, declared, limit } => "theorem verification field {field} has {declared}, limit {limit}";
Self::CounterOverflow { field } => "theorem verification field {field} overflows usize";
Self::Ext(error) => "independent self-Ext calculation failed: {error}";
Self::LocusMismatch { representative } => "independent self-Ext calculation disagrees at representative {representative}";
} }
error_source! { SelfExtLocusArtifactError {
Self::Checkpoint(error) => Some(error),
Self::Ext(error) => Some(error),
_ => None,
} }
impl From<HomologicalStreamPortableError> for SelfExtLocusArtifactError {
fn from(error: HomologicalStreamPortableError) -> Self {
Self::Checkpoint(error)
}
}
impl From<ExtError> for SelfExtLocusArtifactError {
fn from(error: ExtError) -> Self {
Self::Ext(error)
}
}