This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 244cd9291 feat: add get_{ref, mut} to arrow_ipc Reader and Writer
(#4122)
244cd9291 is described below
commit 244cd92915901ab9b713182623d139d4aeec993c
Author: Yilin Chen <[email protected]>
AuthorDate: Tue Apr 25 21:35:07 2023 +0800
feat: add get_{ref, mut} to arrow_ipc Reader and Writer (#4122)
Signed-off-by: Yilin Chen <[email protected]>
---
arrow-ipc/src/reader.rs | 28 ++++++++++++++++++++++++++++
arrow-ipc/src/writer.rs | 24 ++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs
index e41119937..16cb99b92 100644
--- a/arrow-ipc/src/reader.rs
+++ b/arrow-ipc/src/reader.rs
@@ -1038,6 +1038,20 @@ impl<R: Read + Seek> FileReader<R> {
))),
}
}
+
+ /// Gets a reference to the underlying reader.
+ ///
+ /// It is inadvisable to directly read from the underlying reader.
+ pub fn get_ref(&self) -> &R {
+ self.reader.get_ref()
+ }
+
+ /// Gets a mutable reference to the underlying reader.
+ ///
+ /// It is inadvisable to directly read from the underlying reader.
+ pub fn get_mut(&mut self) -> &mut R {
+ self.reader.get_mut()
+ }
}
impl<R: Read + Seek> Iterator for FileReader<R> {
@@ -1243,6 +1257,20 @@ impl<R: Read> StreamReader<R> {
)),
}
}
+
+ /// Gets a reference to the underlying reader.
+ ///
+ /// It is inadvisable to directly read from the underlying reader.
+ pub fn get_ref(&self) -> &R {
+ self.reader.get_ref()
+ }
+
+ /// Gets a mutable reference to the underlying reader.
+ ///
+ /// It is inadvisable to directly read from the underlying reader.
+ pub fn get_mut(&mut self) -> &mut R {
+ self.reader.get_mut()
+ }
}
impl<R: Read> Iterator for StreamReader<R> {
diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index 0c9ca17b7..abaecea1f 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -832,6 +832,18 @@ impl<W: Write> FileWriter<W> {
Ok(())
}
+ /// Gets a reference to the underlying writer.
+ pub fn get_ref(&self) -> &W {
+ self.writer.get_ref()
+ }
+
+ /// Gets a mutable reference to the underlying writer.
+ ///
+ /// It is inadvisable to directly write to the underlying writer.
+ pub fn get_mut(&mut self) -> &mut W {
+ self.writer.get_mut()
+ }
+
/// Unwraps the BufWriter housed in FileWriter.writer, returning the
underlying
/// writer
///
@@ -920,6 +932,18 @@ impl<W: Write> StreamWriter<W> {
Ok(())
}
+ /// Gets a reference to the underlying writer.
+ pub fn get_ref(&self) -> &W {
+ self.writer.get_ref()
+ }
+
+ /// Gets a mutable reference to the underlying writer.
+ ///
+ /// It is inadvisable to directly write to the underlying writer.
+ pub fn get_mut(&mut self) -> &mut W {
+ self.writer.get_mut()
+ }
+
/// Unwraps the BufWriter housed in StreamWriter.writer, returning the
underlying
/// writer
///