diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6cfdb..94b4956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **Breaking:** `compcol::lzma2::Encoder` is now a normal (stateful) struct + instead of the former permanently-`Unsupported` unit-struct stub, because the + working encoder buffers chunk state. As a result it **no longer implements + `Copy`** and can no longer be constructed via a unit-struct literal; construct + it through `Lzma2::encoder()` as with every other codec. It still derives + `Debug` + `Clone`. (No effect on the decoder or any other codec.) - **lz5 (Lizard) Huffman sub-streams** stay `Unsupported`, now with a precise rationale in the module docs: the Huff0 entropy stage selects X1/X2 from `(regenSize, comprLen)` at runtime and there is no reference encoder or diff --git a/src/lzma2/mod.rs b/src/lzma2/mod.rs index 41eb5ba..44d06cc 100644 --- a/src/lzma2/mod.rs +++ b/src/lzma2/mod.rs @@ -225,6 +225,11 @@ enum EncPhase { /// (dict + props + state) at the chunk boundary, emitting a compressed chunk /// (control `0xE0`) when that shrinks the data and an uncompressed chunk /// (control `0x01`) otherwise. +/// +/// Note: unlike the former permanently-`Unsupported` stub (a unit struct), +/// the working encoder buffers state, so it is a normal struct and is no +/// longer `Copy` — construct it via [`Lzma2::encoder()`](crate::Algorithm). +#[derive(Debug, Clone)] pub struct Encoder { phase: EncPhase, /// Staged bytes for the current chunk (or end marker), drained to the diff --git a/src/lzma2_internal/lzma2_encoder.rs b/src/lzma2_internal/lzma2_encoder.rs index bf1ad94..69dadd4 100644 --- a/src/lzma2_internal/lzma2_encoder.rs +++ b/src/lzma2_internal/lzma2_encoder.rs @@ -103,7 +103,7 @@ const NIL: u32 = u32::MAX; /// raise `nice_match` (the length at which the chain walk gives up and /// accepts the current match). This is the same speed-vs-ratio knob that /// xz-utils exposes — we just expose a small subset. -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub(crate) struct EncoderParams { pub max_chain: usize, pub nice_match: u32,