pub fn read_index(&mut self) -> io::Result<Index> {
        let mut buf = String::new();
        let mut index = Vec::new();

        loop {
            buf.clear();

            match read_line(&mut self.inner, &mut buf) {
                Ok(0) => break,
                Ok(_) => {
                    let record = buf
                        .parse()
                        .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;

                    index.push(record);
                }
                Err(e) => return Err(e),
            }
        }

        Ok(index)
    }
/// Reads a CRAM index.
///
/// The position of the stream is expected to be at the start.
///
/// # Examples
///
/// ```no_run
/// # use std::{fs::File, io};
/// use noodles_cram::crai;
/// let mut reader = File::open("sample.cram.crai").map(crai::Reader::new)?;
/// let index = reader.read_index()?;
/// # Ok::<(), io::Error>(())
/// ```
Reads a CRAM index.
The position of the stream is expected to be at the start.
Reads a CRAM index . The position of the stream is expected to be at the start .
pub fn read_index(&mut self) -> io::Result<Index> {
        let mut buf = String::new();
        let mut index = Vec::new();
        loop {
            buf.clear();
            match read_line(&mut self.inner, &mut buf) {
                Ok(0) => break,
                Ok(_) => {
                    let record = buf
                        .parse()
                        .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
                    index.push(record);
                }
                Err(e) => return Err(e),
            }
        }
        Ok(index)
    }
pub fn read_index ( & mut self ) -> io :: Result < Index > { let mut buf = String :: new ( ) ; let mut index = Vec :: new ( ) ; loop { buf . clear ( ) ; match read_line ( & mut self . inner , & mut buf ) { Ok ( 0 ) => break , Ok ( _ ) => { let record = buf . parse ( ) . map_err ( | e | io :: Error :: new ( io :: ErrorKind :: InvalidData , e ) ) ? ; index . push ( record ) ; } Err ( e ) => return Err ( e ) , } } Ok ( index ) }
Reads a CRAM index.
Reads a CRAM index .
&mut self
&mut self
examples
None
use std::{fs::file, io};
use noodles_cram::crai;
let mut reader = File::open("sample.cram.crai").map(crai::Reader::new)?;
let index = reader.read_index()?.
use noodles_cram :: crai ; let mut reader = File :: open ( " sample . cram . crai " ) . map ( crai :: Reader :: new ) ? ; let index = reader . read_index () ? .
ok::<(), io::error>(())
None