pdfrum_cmap/error.rs
1//! The crate's error type.
2//!
3//! Almost nothing here can fail. Reading a CMap program, resolving a
4//! predefined name and decoding a string are all total: damage is recorded
5//! through [`Diagnostics`](pdfrum_common::Diagnostics) and a best-effort value
6//! comes back. The one genuinely fallible operation is looking a name up
7//! against the built-in tables and finding nothing — and even that has a
8//! total counterpart in [`from_encoding_name`](crate::from_encoding_name),
9//! which is what callers normally want.
10
11/// Something a CMap operation could not do.
12#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
13#[non_exhaustive]
14pub enum Error {
15 /// The `/Encoding` name is not one of the built-in CMaps and is not
16 /// `Identity-H` or `Identity-V`.
17 ///
18 /// This is rarely fatal: a file naming an unknown CMap still renders,
19 /// because the fallback decodes two-byte codes and maps each to itself.
20 /// [`from_encoding_name`](crate::from_encoding_name) builds that fallback
21 /// instead of returning this.
22 #[error("no predefined CMap is named {name:?}")]
23 UnknownPredefinedCMap {
24 /// The name as it was asked for, before any suffix handling.
25 name: Vec<u8>,
26 },
27}