pub async fn seek(&mut self, pos: VirtualPosition) -> io::Result<VirtualPosition> {
        let stream = self.stream.take().expect("missing stream");
        let mut blocks = stream.into_inner();

        blocks.seek(pos).await?;

        let mut stream = blocks.try_buffered(self.worker_count);

        self.block = match stream.try_next().await? {
            Some(mut block) => {
                let (cpos, upos) = pos.into();

                self.position = cpos + block.clen();

                block.set_cpos(cpos);
                block.set_upos(usize::from(upos));

                block
            }
            None => Block::default(),
        };

        self.stream.replace(stream);

        Ok(pos)
    }
/// Seeks the stream to the given virtual position.
///
/// # Examples
///
/// ```
/// # use std::io::{self, Cursor};
/// #
/// # #[tokio::main]
/// # async fn main() -> io::Result<()> {
/// use noodles_bgzf as bgzf;
/// let mut reader = bgzf::AsyncReader::new(Cursor::new(Vec::new()));
/// let virtual_position = bgzf::VirtualPosition::from(102334155);
/// reader.seek(virtual_position).await?;
/// # Ok(())
/// # }
/// ```
Seeks the stream to the given virtual position.
Seeks the stream to the given virtual position .
pub async fn seek(&mut self, pos: VirtualPosition) -> io::Result<VirtualPosition> {
        let stream = self.stream.take().expect("missing stream");
        let mut blocks = stream.into_inner();
        blocks.seek(pos).await?;
        let mut stream = blocks.try_buffered(self.worker_count);
        self.block = match stream.try_next().await? {
            Some(mut block) => {
                let (cpos, upos) = pos.into();
                self.position = cpos + block.clen();
                block.set_cpos(cpos);
                block.set_upos(usize::from(upos));
                block
            }
            None => Block::default(),
        };
        self.stream.replace(stream);
        Ok(pos)
    }
pub async fn seek ( & mut self , pos : VirtualPosition ) -> io :: Result < VirtualPosition > { let stream = self . stream . take ( ) . expect ( " " ) ; let mut blocks = stream . into_inner ( ) ; blocks . seek ( pos ) . await ? ; let mut stream = blocks . try_buffered ( self . worker_count ) ; self . block = match stream . try_next ( ) . await ? { Some ( mut block ) => { let ( cpos , upos ) = pos . into ( ) ; self . position = cpos + block . clen ( ) ; block . set_cpos ( cpos ) ; block . set_upos ( usize :: from ( upos ) ) ; block } None => Block :: default ( ) , } ; self . stream . replace ( stream ) ; Ok ( pos ) }
Seeks the stream to the given virtual position.
Seeks the stream to the given virtual position .
&mut self
pos
VirtualPosition
&mut self
pos
VirtualPosition
examples
None
use std::io::{self, cursor};
None
#[tokio::main]
None
async fn main() -> io::result<()> {
use noodles_bgzf as bgzf;
let mut reader = bgzf::AsyncReader::new(Cursor::new(Vec::new()));
let virtual_position = bgzf::VirtualPosition::from(102334155);
reader.seek(virtual_position).await?.
use noodles_bgzf as bgzf ; let mut reader = bgzf :: AsyncReader :: new ( Cursor :: new ( Vec :: new () )) ; let virtual_position = bgzf :: VirtualPosition :: from ( 102334155 ) ; reader . seek ( virtual_position ) . await? .
ok(())
None
}
None