georust / geozero

Zero-Copy reading and writing of geospatial data.
Apache License 2.0
336 stars 33 forks source link

ensure complete writes #32

Closed michaelkirk closed 2 years ago

michaelkirk commented 2 years ago

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.