Kriskras99 commented on code in PR #445:
URL: https://github.com/apache/avro-rs/pull/445#discussion_r2733418409
##########
avro/src/writer.rs:
##########
@@ -617,44 +630,54 @@ impl<T> SpecificSingleObjectWriter<T>
where
T: AvroSchema + Into<Value>,
{
- /// Write the `Into<Value>` to the provided Write object. Returns a result
with the number
- /// of bytes written including the header
- pub fn write_value<W: Write>(&mut self, data: T, writer: &mut W) ->
AvroResult<usize> {
- let v: Value = data.into();
- self.inner.write_value_ref(&v, writer)
+ /// Write the value to the writer
+ ///
+ /// Returns the number of bytes written.
+ ///
+ /// Each call writes a complete single-object encoded message (header +
data),
+ /// making each message independently decodable.
+ pub fn write_value<W: Write>(&self, data: T, writer: &mut W) ->
AvroResult<usize> {
+ writer
+ .write_all(&self.header)
+ .map_err(Details::WriteBytes)?;
+ let value: Value = data.into();
+ let bytes = write_value_ref_owned_resolved(&self.resolved, &value,
writer)?;
Review Comment:
`writer.write_all(&buffer)` can also fail partway through.
I don't think this is worth the performance penalty.
--
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]