Skip to content

Evaluate error recovery for io::EncoderWriter::finish #10

Open

Description

@tisonkun

Context

Low-level Encoder::finish and Decoder::finish return FinishError<Self, E> so callers can recover the unchanged stream state and retry on failure. By contrast, io::EncoderWriter::finish(mut self) -> io::Result<W> in bases/src/io.rs consumes self and returns io::Error directly; if flushing buffered output or writing the final quantum fails (for instance on ErrorKind::WouldBlock or a transient sink failure) when EncoderWriter owns W, the caller loses both W and the buffered tail.

Considerations

  • Evaluate returning a recoverable error wrapper modeled on std::io::BufWriter::into_inner (IntoInnerError-style carrying EncoderWriter<C, W> and io::Error, with From<...> for io::Error so ? remains ergonomic), or exposing a &mut self finalization flush alongside into_inner.
  • Weigh recovery ergonomics for network and file writers against keeping the signature minimal when most callers write to in-memory buffers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions