Skip to content

feat(io): preserve encoder writer state on finish failure - #32

Open
patrickZWY wants to merge 1 commit into
fast:mainfrom
patrickZWY:feat/encoder-writer-finish-recovery
Open

patrickZWY wants to merge 1 commit into
fast:mainfrom
patrickZWY:feat/encoder-writer-finish-recovery

Conversation

@patrickZWY

Copy link
Copy Markdown
Contributor

Summary

Change EncoderWriter::finish from io::Result<W> to Result<W, FinishError<Self, io::Error>> so I/O failures preserve the adapter and remaining output for retry. Conversion to io::Error keeps ? available in functions returning io::Result when recovery is not needed.

Closes #10.

Design Notes

  • Reuse the existing consuming finalization API and FinishError. I/O recovery preserves write progress; Encoder and Decoder retain unchanged-state recovery. Store the adapter directly in the error, accepting a larger error value without an extra heap allocation.
  • Calling finish ends input. Recovered adapters reject nonempty writes with BrokenPipe; retrying finish resumes from the first unwritten byte.
  • Dropping a finalization error or recovered adapter does not retry adapter finalization. Adapters dropped without calling finish retain best-effort finalization; the underlying writer is still dropped normally.

Validation

  • cargo x test on stable and Rust 1.88.0, including shared I/O recovery contracts across all 24 profiles and focused error propagation, drop, and panic regressions.
  • cargo x check and cargo x lint.

Co-authored-by: Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Evaluate error recovery for io::EncoderWriter::finish

1 participant