The documentation for Write::write says that
A call to write represents at most one attempt to write to any wrapped object.
A strict interpretation of this poses problems for writer wrappers like compressors that have to buffer data, process it, and then write it out. If the internal buffer is full, the only thing write can do is write the internal buffer out and then return an error indicating that the caller must retry (the only reasonable option here is ErrorKind::Interrupted).
However, in this GitHub comment @alexcrichton says that
Note that the comment in the docs there was largely targeted at atomicity. Basically if you successfully write any bytes then that must be reported back. I think it’s fine, semantically, for an auto-retry to happen on EINTR.
This viewpoint makes sense, but it doesn’t really match my interpretation of the documentation. I also don’t know what the pitfalls of this would be.
Is it OK for a wrapped writer to call the inner write multiple times at all? If it is, the documentation should probably be updated to reflect that.