In practice, most implementations of write will completely write small bytes, but it's ultimately up to the underlying implementation if it wants to do a partial write. If we want to be sure the entire input is written out, we should use write_all.
If we did want to use write we'd need some kind of recursion/looping to be sure all the output is written.
Note in some places we use an iowrite method, as in: self.out.iowrite(byte_order as u8)?;, but that implementation safely delegates to write_all so no change is needed for those calls.
In practice, most implementations of
write
will completely write small bytes, but it's ultimately up to the underlying implementation if it wants to do a partial write. If we want to be sure the entire input is written out, we should usewrite_all
.If we did want to use
write
we'd need some kind of recursion/looping to be sure all the output is written.Note in some places we use an
iowrite
method, as in:self.out.iowrite(byte_order as u8)?;
, but that implementation safely delegates towrite_all
so no change is needed for those calls.