Struct noodles_bcf::AsyncReader[][src]

pub struct AsyncReader<R> where
    R: AsyncRead
{ /* fields omitted */ }
Expand description

An async BCF reader.

Examples

use futures::TryStreamExt;
use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut records = reader.records();

while let Some(record) = records.try_next().await? {
    // ...
}

Implementations

Creates an async BCF reader builder.

Examples

use noodles_bcf as bcf;
let data = [];
let builder = bcf::AsyncReader::builder(&data[..]);
let reader = builder.build();

Creates an async BCF reader.

Examples

use noodles_bcf as bcf;
let data = [];
let reader = bcf::AsyncReader::new(&data[..]);

Reads the BCF file format.

The BCF magic number is also checked.

The position of the stream is expected to be at the start.

This returns the major and minor format versions as a tuple.

Examples

use noodles_bcf as bcf;
use tokio::fs::File;
let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
let (major, minor) = reader.read_file_format().await?;

Reads the raw VCF header.

The position of the stream is expected to be directly after the file format.

This returns the raw VCF header as a String. It can subsequently be parsed as a noodles_vcf::Header.

Examples

use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;

let header = reader.read_header().await?;

Reads a single record.

The stream is expected to be directly after the header or at the start of another record.

It is more ergonomic to read records using a stream (see Self::records), but using this method directly allows the reuse of a single Record buffer.

If successful, the record size is returned. If a record size of 0 is returned, the stream reached EOF.

use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut record = bcf::Record::default();
reader.read_record(&mut record).await?;

Returns an (async) stream over records starting from the current (input) stream position.

The (input) stream is expected to be directly after the header or at the start of another record.

Examples

use futures::TryStreamExt;
use noodles_bcf as bcf;
use tokio::fs::File;

let mut reader = File::open("sample.bcf").await.map(bcf::AsyncReader::new)?;
reader.read_file_format().await?;
reader.read_header().await?;

let mut records = reader.records();

while let Some(record) = records.try_next().await? {
    // ...
}

Returns the current virtual position of the underlying BGZF reader.

Examples

use noodles_bcf as bcf;
use noodles_bgzf as bgzf;

let data = Vec::new();
let reader = bcf::AsyncReader::new(&data[..]);
let virtual_position = reader.virtual_position();

assert_eq!(reader.virtual_position(), bgzf::VirtualPosition::from(0));

Seeks the underlying BGZF reader to the given virtual position.

Virtual positions typically come from an associated index file.

Examples

use noodles_bcf as bcf;
use noodles_bgzf as bgzf;

let data = [];
let mut reader = bcf::AsyncReader::new(Cursor::new(data));

let virtual_position = bgzf::VirtualPosition::default();
reader.seek(virtual_position).await?;

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.