Struct noodles_cram::AsyncReader [−][src]
pub struct AsyncReader<R> { /* fields omitted */ }
Expand description
An async CRAM reader.
Implementations
Creates an async CRAM reader.
Examples
use noodles_cram as cram; let data = []; let reader = cram::AsyncReader::new(&data[..]);
Reads the CRAM file definition.
This also checks the magic number.
The position of the stream is expected to be at the start.
Examples
use noodles_cram as cram; use tokio::fs::File; let mut reader = File::open("sample.cram").await.map(cram::AsyncReader::new)?; let file_definition = reader.read_file_definition().await?;
Reads the raw SAM header.
The position of the stream is expected to be at the CRAM header container, i.e., directly after the file definition.
This returns the raw SAM header as a String
. It can subsequently be parsed as a
noodles_sam::Header
.
Examples
use noodles_cram as cram; use tokio::fs::File; let mut reader = File::open("sample.cram").await.map(cram::AsyncReader::new)?; reader.read_file_definition().await?; let header = reader.read_file_header().await?;
Seeks the underlying reader to the given position.
Positions typically come from an associated CRAM index file.
Examples
use std::io::{Cursor, SeekFrom}; use noodles_cram as cram; let mut reader = cram::AsyncReader::new(Cursor::new(Vec::new())); reader.seek(SeekFrom::Start(0)).await?;