fn create_snapshot_data_file_stream<P>(
    snapshot_root_file_path: P,
    maximum_file_size: u64,
) -> Result<(u64, BufReader<File>)>
where
    P: AsRef<Path>,
{
    let snapshot_file_size = fs::metadata(&snapshot_root_file_path)?.len();

    if snapshot_file_size > maximum_file_size {
        let error_message =
            format!(
            "too large snapshot data file to deserialize: {} has {} bytes (max size is {} bytes)",
            snapshot_root_file_path.as_ref().display(), snapshot_file_size, maximum_file_size
        );
        return Err(get_io_error(&error_message));
    }

    let snapshot_data_file = File::open(&snapshot_root_file_path)?;
    let snapshot_data_file_stream = BufReader::new(snapshot_data_file);

    Ok((snapshot_file_size, snapshot_data_file_stream))
}
/// Before running the deserializer function, perform common operations on the snapshot archive
/// files, such as checking the file size and opening the file into a stream.
Before running the deserializer function, perform common operations on the snapshot archive
files, such as checking the file size and opening the file into a stream.
Before running the deserializer function perform common operations on the snapshot archive files such as checking the file size and opening the file into a stream .
fn create_snapshot_data_file_stream<P>(
    snapshot_root_file_path: P,
    maximum_file_size: u64,
) -> Result<(u64, BufReader<File>)>
where
    P: AsRef<Path>,
{
    let snapshot_file_size = fs::metadata(&snapshot_root_file_path)?.len();
    if snapshot_file_size > maximum_file_size {
        let error_message =
            format!(
            "too large snapshot data file to deserialize: {} has {} bytes (max size is {} bytes)",
            snapshot_root_file_path.as_ref().display(), snapshot_file_size, maximum_file_size
        );
        return Err(get_io_error(&error_message));
    }
    let snapshot_data_file = File::open(&snapshot_root_file_path)?;
    let snapshot_data_file_stream = BufReader::new(snapshot_data_file);
    Ok((snapshot_file_size, snapshot_data_file_stream))
}
fn create_snapshot_data_file_stream < P > ( snapshot_root_file_path : P , maximum_file_size : u64 , ) -> Result < ( u64 , BufReader < File > ) > where P : AsRef < Path > , { let snapshot_file_size = fs :: metadata ( & snapshot_root_file_path ) ? . len ( ) ; if snapshot_file_size > maximum_file_size { let error_message = format ! ( " " snapshot_root_file_path as_ref ( ) display ( ) snapshot_file_size maximum_file_size ) ; return Err ( get_io_error ( & error_message ) ) ; } let snapshot_data_file = File :: open ( & snapshot_root_file_path ) ? ; let snapshot_data_file_stream = BufReader :: new ( snapshot_data_file ) ; Ok ( ( snapshot_file_size , snapshot_data_file_stream ) ) }
Before running the deserializer function, perform common operations on the snapshot archive
files, such as checking the file size and opening the file into a stream.
Before running the deserializer function perform common operations on the snapshot archive files such as checking the file size and opening the file into a stream .
snapshot_root_file_path
P
maximum_file_size
u64