pub fn load_from_bin_file<Key, Value, ReadCallback, ProcessedCallback, Reader>(
    file: &mut Reader,
    integrity: &mut Option<Integrity>,
    mut after_read_callback: Option<ReadCallback>,
    mut processed_callback: ProcessedCallback
    ) -> Result<(), LoadFileError>
where
    Key: DeserializeOwned,
    Value: DeserializeOwned,
    ProcessedCallback: FnMut(MapOperation<Key, Value>) -> Result<(), ()>,
    ReadCallback: FnMut(&mut Vec<u8>) -> Result<(), Box<dyn std::error::Error>>,
    Reader: std::io::Read,
{
    let mut reader = BufReader::new(file);
    let mut block_num = 1;
    loop {
        let block_len = read_bin_block_len(&mut reader)?;
        if block_len == 0 {
            return Ok(())
        }

        let mut data_block = vec![0; block_len];
        reader.read_exact(&mut data_block[..])?;

        if let Some(callback) = &mut after_read_callback {
            callback(&mut data_block)
               .map_err(|err| LoadFileError::InterruptedWithBeforeReadCallback(err))?;
        }

        let data_block = if let Some(integrity) = integrity {
            process_block_integrity(&mut data_block, integrity, block_num)?
        } else {
            &data_block[..]
        };

        match data_block[0] {
            INSERT => {
                let (key, val) = bincode2::deserialize(&data_block[1..]).map_err(|err| LoadFileError::DeserializeBincodeError { err, block_num })?;
                processed_callback(MapOperation::Insert(key, val)).map_err(|()| LoadFileError::Interrupted)?;
            }
            REMOVE => {
                let key = bincode2::deserialize(&data_block[1..]).map_err(|err| LoadFileError::DeserializeBincodeError { err, block_num })?;
                processed_callback(MapOperation::Remove(key)).map_err(|()| LoadFileError::Interrupted)?;
            }
            _ => {
            }
        }

        block_num += 1;
    }
}
/// Load from binary format file all map history records and call 'ProcessedCallback' callback for each.
Load from binary format file all map history records and call 'ProcessedCallback' callback for each.
Load from binary format file all map history records and call ' ProcessedCallback ' callback for each .
pub fn load_from_bin_file<Key, Value, ReadCallback, ProcessedCallback, Reader>(
    file: &mut Reader,
    integrity: &mut Option<Integrity>,
    mut after_read_callback: Option<ReadCallback>,
    mut processed_callback: ProcessedCallback
    ) -> Result<(), LoadFileError>
where
    Key: DeserializeOwned,
    Value: DeserializeOwned,
    ProcessedCallback: FnMut(MapOperation<Key, Value>) -> Result<(), ()>,
    ReadCallback: FnMut(&mut Vec<u8>) -> Result<(), Box<dyn std::error::Error>>,
    Reader: std::io::Read,
{
    let mut reader = BufReader::new(file);
    let mut block_num = 1;
    loop {
        let block_len = read_bin_block_len(&mut reader)?;
        if block_len == 0 {
            return Ok(())
        }
        let mut data_block = vec![0; block_len];
        reader.read_exact(&mut data_block[..])?;
        if let Some(callback) = &mut after_read_callback {
            callback(&mut data_block)
               .map_err(|err| LoadFileError::InterruptedWithBeforeReadCallback(err))?;
        }
        let data_block = if let Some(integrity) = integrity {
            process_block_integrity(&mut data_block, integrity, block_num)?
        } else {
            &data_block[..]
        };
        match data_block[0] {
            INSERT => {
                let (key, val) = bincode2::deserialize(&data_block[1..]).map_err(|err| LoadFileError::DeserializeBincodeError { err, block_num })?;
                processed_callback(MapOperation::Insert(key, val)).map_err(|()| LoadFileError::Interrupted)?;
            }
            REMOVE => {
                let key = bincode2::deserialize(&data_block[1..]).map_err(|err| LoadFileError::DeserializeBincodeError { err, block_num })?;
                processed_callback(MapOperation::Remove(key)).map_err(|()| LoadFileError::Interrupted)?;
            }
            _ => {
            }
        }
        block_num += 1;
    }
}
pub fn load_from_bin_file < Key , Value , ReadCallback , ProcessedCallback , Reader > ( file : & mut Reader , integrity : & mut Option < Integrity > , mut after_read_callback : Option < ReadCallback > , mut processed_callback : ProcessedCallback ) -> Result < ( ) , LoadFileError > where Key : DeserializeOwned , Value : DeserializeOwned , ProcessedCallback : FnMut ( MapOperation < Key , Value > ) -> Result < ( ) , ( ) > , ReadCallback : FnMut ( & mut Vec < u8 > ) -> Result < ( ) , Box < dyn std :: error :: Error > > , Reader : std :: io :: Read , { let mut reader = BufReader :: new ( file ) ; let mut block_num = 1 ; loop { let block_len = read_bin_block_len ( & mut reader ) ? ; if block_len == 0 { return Ok ( ( ) ) } let mut data_block = vec ! [ 0 block_len ] ; reader . read_exact ( & mut data_block [ .. ] ) ? ; if let Some ( callback ) = & mut after_read_callback { callback ( & mut data_block ) . map_err ( | err | LoadFileError :: InterruptedWithBeforeReadCallback ( err ) ) ? ; } let data_block = if let Some ( integrity ) = integrity { process_block_integrity ( & mut data_block , integrity , block_num ) ? } else { & data_block [ .. ] } ; match data_block [ 0 ] { INSERT => { let ( key , val ) = bincode2 :: deserialize ( & data_block [ 1 .. ] ) . map_err ( | err | LoadFileError :: DeserializeBincodeError { err , block_num } ) ? ; processed_callback ( MapOperation :: Insert ( key , val ) ) . map_err ( | ( ) | LoadFileError :: Interrupted ) ? ; } REMOVE => { let key = bincode2 :: deserialize ( & data_block [ 1 .. ] ) . map_err ( | err | LoadFileError :: DeserializeBincodeError { err , block_num } ) ? ; processed_callback ( MapOperation :: Remove ( key ) ) . map_err ( | ( ) | LoadFileError :: Interrupted ) ? ; } _ => { } } block_num += 1 ; } }
Load from binary format file all map history records and call 'ProcessedCallback' callback for each.
Load from binary format file all map history records and call ' ProcessedCallback ' callback for each .
file
&mut Reader
integrity
&mut Option<Integrity>
after_read_callback
Option<ReadCallback>
processed_callback
ProcessedCallback
file
&mut Reader
integrity
&mut Option<Integrity>
after_read_callback
Option<ReadCallback>
processed_callback
ProcessedCallback