diff --git a/noodles-vcf/CHANGELOG.md b/noodles-vcf/CHANGELOG.md index e0d2239f5..0127e47b6 100644 --- a/noodles-vcf/CHANGELOG.md +++ b/noodles-vcf/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Unreleased + +### Added + + * vcf/async: Add common methods to access the underlying I/O: + `AsyncReader::get_ref`, `AsyncReader::get_mut`, `AsyncReader::into_inner`, + `AsyncWriter::get_ref`, `AsyncWriter::get_mut`, and + `AsyncWriter::into_inner`. + ## 0.42.0 - 2023-10-19 ### Changed diff --git a/noodles-vcf/src/async/reader.rs b/noodles-vcf/src/async/reader.rs index 61ea9db19..d93fc7554 100644 --- a/noodles-vcf/src/async/reader.rs +++ b/noodles-vcf/src/async/reader.rs @@ -73,6 +73,48 @@ where } } + /// Returns a reference to the underlying reader. + /// + /// # Examples + /// + /// ``` + /// use noodles_vcf as vcf; + /// let data = []; + /// let reader = vcf::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_vcf as vcf; + /// let data = []; + /// let mut reader = vcf::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_vcf as vcf; + /// let data = []; + /// let reader = vcf::AsyncReader::new(&data[..]); + /// assert!(reader.into_inner().is_empty()); + /// ``` + pub fn into_inner(self) -> R { + self.inner + } + /// Reads the VCF header. /// /// This reads all header lines prefixed with a `#` (number sign), which includes the header diff --git a/noodles-vcf/src/async/writer.rs b/noodles-vcf/src/async/writer.rs index 99db28c9e..d32d76acf 100644 --- a/noodles-vcf/src/async/writer.rs +++ b/noodles-vcf/src/async/writer.rs @@ -28,6 +28,45 @@ where Self { inner } } + /// Returns a reference to the underlying writer. + /// + /// # Examples + /// + /// ``` + /// use noodles_vcf as vcf; + /// let writer = vcf::AsyncWriter::new(Vec::new()); + /// assert!(writer.get_ref().is_empty()); + /// ``` + pub fn get_ref(&self) -> &W { + &self.inner + } + + /// Returns a mutable reference to the underlying writer. + /// + /// # Examples + /// + /// ``` + /// use noodles_vcf as vcf; + /// let mut writer = vcf::AsyncWriter::new(Vec::new()); + /// assert!(writer.get_mut().is_empty()); + /// ``` + pub fn get_mut(&mut self) -> &mut W { + &mut self.inner + } + + /// Returns the underlying writer. + /// + /// # Examples + /// + /// ``` + /// use noodles_vcf as vcf; + /// let writer = vcf::AsyncWriter::new(Vec::new()); + /// assert!(writer.into_inner().is_empty()); + /// ``` + pub fn into_inner(self) -> W { + self.inner + } + /// Writes a VCF header. /// /// # Examples