1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Error types for the rpdfium-doc crate.
use thiserror::Error;
/// Errors that can occur during document structure parsing.
#[derive(Debug, Clone, Error)]
pub enum DocError {
/// A required dictionary key is missing.
#[error("missing required key: {0}")]
MissingKey(String),
/// An object had an unexpected type.
#[error("unexpected object type")]
UnexpectedType,
/// An error propagated from the parser layer.
#[error("parser error: {0}")]
Parser(String),
/// A tree or linked-list traversal exceeded the maximum allowed depth.
#[error("tree depth exceeded")]
DepthExceeded,
/// The provided value exceeds the field's maximum length.
#[error("value too long: length {len} exceeds max {max}")]
ValueTooLong {
/// Actual length of the value.
len: usize,
/// Maximum allowed length.
max: u32,
},
/// The provided value is not valid for the target field type.
#[error("type mismatch: expected {expected}, got {got}")]
TypeMismatch {
/// The expected value kind.
expected: String,
/// The actual value kind.
got: String,
},
/// A choice index is out of range.
#[error("invalid choice index: {index} (field has {count} options)")]
InvalidChoiceIndex {
/// The requested index.
index: usize,
/// The number of available options.
count: usize,
},
/// The named field was not found in the form.
#[error("field not found: {0}")]
FieldNotFound(String),
/// An index was out of range.
#[error("index out of range: {0}")]
InvalidIndex(usize),
/// The requested named entry was not found.
#[error("not found: {0}")]
NotFound(String),
/// The requested operation is not supported.
///
/// # Not Supported
///
/// Returned by mutation APIs that are intentionally stubbed out because
/// rpdfium is a read-only library (per ADR-017). The contained string
/// describes the unsupported operation.
#[error("not supported: {0}")]
NotSupported(String),
}
/// Convenience result alias for [`DocError`].
pub type DocResult<T> = std::result::Result<T, DocError>;