pub fn load_reader<R>(
    reader: R,
    config: RecordIndexerConfig,
) -> impl Iterator<Item = Result<Position>>
where
    R: Read + Seek,
{
    let RecordIndexerConfig { check_integrity } = config;

    itertools::unfold(Some(reader), move |reader_opt| {
        let mut reader = reader_opt.as_mut()?;
        let len = match crate::io::sync::try_read_len(&mut reader, check_integrity).transpose()? {
            Ok(len) => len,
            Err(err) => {
                *reader_opt = None;
                return Some(Err(err));
            }
        };

        let offset = (move || {
            let offset = reader.seek(SeekFrom::Current(0))?;
            skip_or_check(&mut reader, len, check_integrity)?;
            Ok(offset)
        })();
        let offset = match offset {
            Ok(offset) => offset,
            Err(err) => {
                *reader_opt = None;
                return Some(Err(err));
            }
        };

        let pos = Position { offset, len };
        Some(Ok(pos))
    })
}
/// Load record indexes from a reader.
Load record indexes from a reader.
Load record indexes from a reader .
pub fn load_reader<R>(
    reader: R,
    config: RecordIndexerConfig,
) -> impl Iterator<Item = Result<Position>>
where
    R: Read + Seek,
{
    let RecordIndexerConfig { check_integrity } = config;
    itertools::unfold(Some(reader), move |reader_opt| {
        let mut reader = reader_opt.as_mut()?;
        let len = match crate::io::sync::try_read_len(&mut reader, check_integrity).transpose()? {
            Ok(len) => len,
            Err(err) => {
                *reader_opt = None;
                return Some(Err(err));
            }
        };
        let offset = (move || {
            let offset = reader.seek(SeekFrom::Current(0))?;
            skip_or_check(&mut reader, len, check_integrity)?;
            Ok(offset)
        })();
        let offset = match offset {
            Ok(offset) => offset,
            Err(err) => {
                *reader_opt = None;
                return Some(Err(err));
            }
        };
        let pos = Position { offset, len };
        Some(Ok(pos))
    })
}
pub fn load_reader < R > ( reader : R , config : RecordIndexerConfig , ) -> impl Iterator < Item = Result < Position > > where R : Read + Seek , { let RecordIndexerConfig { check_integrity } = config ; itertools :: unfold ( Some ( reader ) , move | reader_opt | { let mut reader = reader_opt . as_mut ( ) ? ; let len = match crate :: io :: sync :: try_read_len ( & mut reader , check_integrity ) . transpose ( ) ? { Ok ( len ) => len , Err ( err ) => { * reader_opt = None ; return Some ( Err ( err ) ) ; } } ; let offset = ( move | | { let offset = reader . seek ( SeekFrom :: Current ( 0 ) ) ? ; skip_or_check ( & mut reader , len , check_integrity ) ? ; Ok ( offset ) } ) ( ) ; let offset = match offset { Ok ( offset ) => offset , Err ( err ) => { * reader_opt = None ; return Some ( Err ( err ) ) ; } } ; let pos = Position { offset , len } ; Some ( Ok ( pos ) ) } ) }
Load record indexes from a reader.
Load record indexes from a reader .
reader
R
config
RecordIndexerConfig
reader
R
config
RecordIndexerConfig