Skip to content

Commit 1f7b764

Browse files
elementmercclaude
andcommitted
fix: replace thiserror with manual Display/Error impls; drop all dependencies
thiserror's transitive chain (thiserror → thiserror-impl → proc-macro2) now requires rustc ≥ 1.68, breaking the MSRV 1.56 check even after downgrading to v1. Manual impls are 15 lines and eliminate the entire [dependencies] section, making the MSRV check unconditionally stable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d11eacd commit 1f7b764

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ categories = ["multimedia::images", "encoding", "parser-implementations"]
1111
readme = "README.md"
1212
rust-version = "1.56"
1313

14-
[dependencies]
15-
thiserror = "1"
1614

1715
[dev-dependencies]
1816
image = { version = "0.25", default-features = false, features = ["jpeg"] }

src/lib.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,52 @@
5454
//! std::fs::write("photo_modified.jpg", modified).unwrap();
5555
//! ```
5656
57-
use thiserror::Error;
58-
5957
// ── Public error type ─────────────────────────────────────────────────────────
6058

6159
/// Errors returned by this crate.
62-
#[derive(Debug, Error)]
60+
#[derive(Debug)]
6361
pub enum DctError {
6462
/// The input does not start with a JPEG SOI marker (`0xFF 0xD8`).
65-
#[error("not a JPEG file")]
6663
NotJpeg,
6764

6865
/// The input was truncated mid-marker or mid-entropy-stream.
69-
#[error("truncated JPEG data")]
7066
Truncated,
7167

7268
/// The entropy-coded data contains an invalid Huffman symbol or an
7369
/// unexpected structure.
74-
#[error("corrupt or malformed JPEG entropy stream")]
7570
CorruptEntropy,
7671

7772
/// The JPEG uses a feature this crate does not support (e.g. progressive
7873
/// scan, lossless, or arithmetic coding).
79-
#[error("unsupported JPEG variant: {0}")]
8074
Unsupported(String),
8175

8276
/// A required marker or table is missing from the JPEG (e.g. no SOF, no
8377
/// SOS, or a scan references a Huffman table that was not defined).
84-
#[error("missing required JPEG structure: {0}")]
8578
Missing(String),
8679

8780
/// The `JpegCoefficients` passed to [`write_coefficients`] is not
8881
/// compatible with the JPEG (wrong number of components, wrong block
8982
/// count, wrong component index).
90-
#[error("coefficient data is incompatible with this JPEG: {0}")]
9183
Incompatible(String),
9284
}
9385

86+
impl core::fmt::Display for DctError {
87+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
88+
match self {
89+
DctError::NotJpeg => f.write_str("not a JPEG file"),
90+
DctError::Truncated => f.write_str("truncated JPEG data"),
91+
DctError::CorruptEntropy => f.write_str("corrupt or malformed JPEG entropy stream"),
92+
DctError::Unsupported(s) => write!(f, "unsupported JPEG variant: {}", s),
93+
DctError::Missing(s) => write!(f, "missing required JPEG structure: {}", s),
94+
DctError::Incompatible(s) => {
95+
write!(f, "coefficient data is incompatible with this JPEG: {}", s)
96+
}
97+
}
98+
}
99+
}
100+
101+
impl std::error::Error for DctError {}
102+
94103
// ── Public types ──────────────────────────────────────────────────────────────
95104

96105
/// Metadata for a single image component, as read from the SOF marker.

0 commit comments

Comments
 (0)