use cadmpeg_core::decode::DecodeDepth;
use crate::report::{
loss::{LossKind, LossNamespace, LossNote, LossTaxonomy, NamespacedLossKind},
Severity,
};
const NAMESPACE: LossNamespace<'static> = crate::loss_namespace!("decode");
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum DecodeLossCode {
DepthNotDelivered {
delivered: DecodeDepth,
},
}
impl DecodeLossCode {
const fn code(self) -> &'static str {
match self {
Self::DepthNotDelivered { .. } => "depth.not-delivered",
}
}
const fn severity(self) -> Severity {
match self {
Self::DepthNotDelivered { .. } => Severity::Error,
}
}
const fn shared_taxonomy(self) -> LossTaxonomy {
let Self::DepthNotDelivered { delivered } = self;
match delivered {
DecodeDepth::Container => LossTaxonomy::GeometryNotTransferred,
DecodeDepth::Geometry | DecodeDepth::Full => LossTaxonomy::ParametricRecordOmitted,
}
}
fn kind(self) -> LossKind {
NamespacedLossKind::new(NAMESPACE, self.code(), self.shared_taxonomy())
.with_strict_floor(Some(Severity::Warning))
.into()
}
pub(crate) fn note(self, message: impl Into<String>) -> LossNote {
LossNote::new(self.kind(), message).with_severity(self.severity())
}
}