Skip to content

Commit

Permalink
feat: add get_{ref, mut} to arrow_ipc Reader and Writer
Browse files Browse the repository at this point in the history
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
  • Loading branch information
sticnarf committed Apr 25, 2023
1 parent 6099864 commit c01c945
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
28 changes: 28 additions & 0 deletions arrow-ipc/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down
24 changes: 24 additions & 0 deletions arrow-ipc/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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
///
Expand Down

0 comments on commit c01c945

Please sign in to comment.