Phoenix500526 commented on code in PR #10277:
URL: https://github.com/apache/arrow-rs/pull/10277#discussion_r3607351280
##########
arrow-ipc/src/writer.rs:
##########
@@ -135,6 +135,165 @@ impl<'a> IpcBodySink<'a> {
}
}
+/// Destination for a complete framed IPC message.
+///
+/// This emits the stream/file framing around the serialized FlatBuffer
+/// [`crate::Message`] metadata plus its optional body buffers.
+enum IpcMessageSink<'a> {
+ /// Write bytes directly to a synchronous writer.
+ Writer(&'a mut dyn Write),
+ /// Accumulate ordered buffers for deferred writing.
+ Buffers(&'a mut Vec<Buffer>),
+}
+
+impl IpcMessageSink<'_> {
+ fn write_vec(&mut self, bytes: Vec<u8>) -> Result<(), ArrowError> {
+ if bytes.is_empty() {
+ return Ok(());
+ }
+
+ match self {
+ Self::Writer(writer) => writer.write_all(&bytes)?,
+ Self::Buffers(out) => out.push(Buffer::from(bytes)),
+ }
+ Ok(())
+ }
+
+ fn write_encoded_buffer(&mut self, buffer: EncodedBuffer) -> Result<(),
ArrowError> {
Review Comment:
I added some doc comments to those methods that are mainly called from
outside `IpcMessageSink`.
FYI:[5cfcf8a](https://github.com/apache/arrow-rs/pull/10277/commits/5cfcf8a13944a52163b8f04878b6ecf2458f70d2)
--
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]