use crate::PageId;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ResourceKind {
Font,
Image,
DrawParam,
}
impl std::fmt::Display for ResourceKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ResourceKind::Font => write!(f, "font"),
ResourceKind::Image => write!(f, "image"),
ResourceKind::DrawParam => write!(f, "draw param"),
}
}
}
#[derive(Debug, Clone)]
pub enum OfdWarning {
MissingFeature { feature: String, entry: String },
SkippedObject { page: PageId, reason: String },
FontSubstituted { requested: String, used: String },
ResourceNotFound { kind: ResourceKind, id: String },
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn missing_feature_warning_displays_feature() {
let w = OfdWarning::MissingFeature {
feature: "JBIG2".into(),
entry: "Doc_0/Res/Img_0.xml".into(),
};
assert!(format!("{w:?}").contains("JBIG2"));
}
#[test]
fn resource_kind_display() {
assert_eq!(ResourceKind::Font.to_string(), "font");
assert_eq!(ResourceKind::Image.to_string(), "image");
assert_eq!(ResourceKind::DrawParam.to_string(), "draw param");
}
}