From 16039b2be721c045a8f8d501966ace9eb9b1b902 Mon Sep 17 00:00:00 2001 From: Michael Macias Date: Sun, 16 Jun 2024 11:20:21 -0500 Subject: [PATCH] bgzf/gzi/reader: Add common methods to access the underlying reader --- noodles-bgzf/CHANGELOG.md | 6 +++++ noodles-bgzf/src/gzi/reader.rs | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/noodles-bgzf/CHANGELOG.md b/noodles-bgzf/CHANGELOG.md index 29f26ef5b..50ad0290e 100644 --- a/noodles-bgzf/CHANGELOG.md +++ b/noodles-bgzf/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Added + + * bgzf/gzi/reader: Add common methods to access the underlying reader. + ## 0.30.0 - 2024-05-16 ### Added diff --git a/noodles-bgzf/src/gzi/reader.rs b/noodles-bgzf/src/gzi/reader.rs index 6532ecbe7..0859b7c35 100644 --- a/noodles-bgzf/src/gzi/reader.rs +++ b/noodles-bgzf/src/gzi/reader.rs @@ -9,6 +9,50 @@ pub struct Reader { inner: R, } +impl Reader { + /// Returns a reference to the underlying reader. + /// + /// # Examples + /// + /// ``` + /// # use std::io; + /// use noodles_bgzf::gzi; + /// let reader = gzi::Reader::new(io::empty()); + /// let _inner = reader.get_ref(); + /// ``` + pub fn get_ref(&self) -> &R { + &self.inner + } + + /// Returns a mutable reference to the underlying reader. + /// + /// # Examples + /// + /// ``` + /// # use std::io; + /// use noodles_bgzf::gzi; + /// let mut reader = gzi::Reader::new(io::empty()); + /// let _inner = reader.get_mut(); + /// ``` + pub fn get_mut(&mut self) -> &mut R { + &mut self.inner + } + + /// Returns the underlying reader. + /// + /// # Examples + /// + /// ``` + /// # use std::io; + /// use noodles_bgzf::gzi; + /// let reader = gzi::Reader::new(io::empty()); + /// let _inner = reader.into_inner(); + /// ``` + pub fn into_inner(self) -> R { + self.inner + } +} + impl Reader where R: Read,