Skip to content

Commit

Permalink
cram/async/reader: Add common methods to access the underlying reader
Browse files Browse the repository at this point in the history
Closes #220.
  • Loading branch information
zaeleus committed Dec 7, 2023
1 parent 0e2aafc commit 8de299b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions noodles-cram/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Unreleased

### Added

* cram/async/reader: Add common methods to access the underlying reader:
`get_ref`, `get_mut`, and `into_inner` ([#220]).

[#220]: /~https://github.com/zaeleus/noodles/issues/220

## 0.50.0 - 2023-11-14

### Changed
Expand Down
42 changes: 42 additions & 0 deletions noodles-cram/src/async/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,48 @@ where
}
}

/// Returns a reference to the underlying reader.
///
/// # Examples
///
/// ```
/// use noodles_cram as cram;
/// let data = [];
/// let reader = cram::AsyncReader::new(&data[..]);
/// assert!(reader.get_ref().is_empty());
/// ```
pub fn get_ref(&self) -> &R {
&self.inner
}

/// Returns a mutable reference to the underlying reader.
///
/// # Examples
///
/// ```
/// use noodles_cram as cram;
/// let data = [];
/// let mut reader = cram::AsyncReader::new(&data[..]);
/// assert!(reader.get_mut().is_empty());
/// ```
pub fn get_mut(&mut self) -> &mut R {
&mut self.inner
}

/// Returns the underlying reader.
///
/// # Examples
///
/// ```
/// use noodles_cram as cram;
/// let data = [];
/// let reader = cram::AsyncReader::new(&data[..]);
/// assert!(reader.into_inner().is_empty());
/// ```
pub fn into_inner(self) -> R {
self.inner
}

/// Reads the CRAM file definition.
///
/// This also checks the magic number.
Expand Down

0 comments on commit 8de299b

Please sign in to comment.