Skip to main content

rpdfium_codec/
error.rs

1// Derived from PDFium's codec error handling patterns
2// Original: Copyright 2014 The PDFium Authors
3// Licensed under BSD-3-Clause / Apache-2.0
4// See pdfium-upstream/LICENSE for the original license.
5
6//! Error types for the codec crate.
7
8use thiserror::Error;
9
10/// Errors that can occur during stream decoding.
11#[derive(Debug, Error)]
12pub enum DecodeError {
13    /// The input data is malformed or truncated.
14    #[error("invalid input: {0}")]
15    InvalidInput(String),
16
17    /// Decompressed output exceeds the allowed size limit.
18    #[error("decompressed size exceeds limit of {limit} bytes")]
19    OutputTooLarge {
20        /// The configured size limit.
21        limit: u64,
22    },
23
24    /// The filter chain exceeds the maximum allowed length.
25    #[error("filter chain length {length} exceeds limit of {limit}")]
26    FilterChainTooLong {
27        /// The actual chain length.
28        length: usize,
29        /// The configured limit.
30        limit: u32,
31    },
32
33    /// A flate (zlib) decompression error.
34    #[error("flate decompression error: {0}")]
35    Flate(String),
36
37    /// A JPEG decoding error.
38    #[error("JPEG decode error: {0}")]
39    Jpeg(String),
40
41    /// A predictor processing error.
42    #[error("predictor error: {0}")]
43    Predictor(String),
44
45    /// The requested filter is not yet implemented.
46    #[error("{0} decoding is not yet implemented")]
47    NotImplemented(String),
48}