This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
Fix FmtToIoWriter::write_str to call write_all #206
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I experienced bytes being silently dropped when serializing large objects to compressed files using
serde_yaml
andflate2
/bzip2
. I believe this PR will fix the issue, but I haven't tested it yet to confirm. Regardless, it's clear that this change is necessary so thatFmtToIoWriter
meets the contract ofstd::fmt::Write
.Previously, the implementation could silently fail to write some bytes. Now, the implementation should either write all the bytes or return an error.
The docs for
std::fmt::Write::write_str
say, "This method can only succeed if the entire string slice was successfully written, and this method will not return until all data has been written or an error occurs." So,FmtToIoWriter::write_str
must callstd::io::Write::write_all
instead ofstd::io::Write::write
on the inner writer in order to ensure that all the bytes are written.