Skip to content

Commit

Permalink
bgzf/gzi/reader: Add common methods to access the underlying reader
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Jun 16, 2024
1 parent 49e604a commit 16039b2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions noodles-bgzf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
44 changes: 44 additions & 0 deletions noodles-bgzf/src/gzi/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,50 @@ pub struct Reader<R> {
inner: R,
}

impl<R> Reader<R> {
/// 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<R> Reader<R>
where
R: Read,
Expand Down

0 comments on commit 16039b2

Please sign in to comment.