martin-g commented on code in PR #438:
URL: https://github.com/apache/avro-rs/pull/438#discussion_r2726917385
##########
avro/src/writer.rs:
##########
@@ -632,24 +630,27 @@ where
T: AvroSchema + Serialize,
{
/// Write the referenced `Serialize` object to the provided `Write`
object. Returns a result with
- /// the number of bytes written including the header
+ /// the number of bytes written including the header.
+ ///
+ /// Each call writes a complete single-object encoded message (header +
data),
+ /// making each message independently decodable.
pub fn write_ref<W: Write>(&mut self, data: &T, writer: &mut W) ->
AvroResult<usize> {
- let mut bytes_written: usize = 0;
-
- if !self.header_written {
- bytes_written += writer
- .write(self.inner.buffer.as_slice())
- .map_err(Details::WriteBytes)?;
- self.header_written = true;
- }
+ // Always write the header for each message (single object encoding
requires
+ // each message to be independently decodable)
+ let mut bytes_written = writer
+ .write(self.inner.buffer.as_slice())
Review Comment:
```suggestion
.write_all(self.inner.buffer.as_slice())
```
like GenericSingleObjectWriter
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]