fn snapshot_version_from_file(path: impl AsRef<Path>) -> Result<String> {
    // Check file size.
    let file_size = fs::metadata(&path)?.len();
    if file_size > MAX_SNAPSHOT_VERSION_FILE_SIZE {
        let error_message = format!(
            "snapshot version file too large: {} has {} bytes (max size is {} bytes)",
            path.as_ref().display(),
            file_size,
            MAX_SNAPSHOT_VERSION_FILE_SIZE,
        );
        return Err(get_io_error(&error_message));
    }

    // Read snapshot_version from file.
    let mut snapshot_version = String::new();
    File::open(path).and_then(|mut f| f.read_to_string(&mut snapshot_version))?;
    Ok(snapshot_version.trim().to_string())
}
/// Reads the `snapshot_version` from a file. Before opening the file, its size
/// is compared to `MAX_SNAPSHOT_VERSION_FILE_SIZE`. If the size exceeds this
/// threshold, it is not opened and an error is returned.
Reads the `snapshot_version` from a file. Before opening the file, its size
is compared to `MAX_SNAPSHOT_VERSION_FILE_SIZE`. If the size exceeds this
threshold, it is not opened and an error is returned.
Reads the ` snapshot_version ` from a file . Before opening the file its size is compared to ` MAX_SNAPSHOT_VERSION_FILE_SIZE ` . If the size exceeds this threshold it is not opened and an error is returned .
fn snapshot_version_from_file(path: impl AsRef<Path>) -> Result<String> {
    // Check file size.
    let file_size = fs::metadata(&path)?.len();
    if file_size > MAX_SNAPSHOT_VERSION_FILE_SIZE {
        let error_message = format!(
            "snapshot version file too large: {} has {} bytes (max size is {} bytes)",
            path.as_ref().display(),
            file_size,
            MAX_SNAPSHOT_VERSION_FILE_SIZE,
        );
        return Err(get_io_error(&error_message));
    }
    // Read snapshot_version from file.
    let mut snapshot_version = String::new();
    File::open(path).and_then(|mut f| f.read_to_string(&mut snapshot_version))?;
    Ok(snapshot_version.trim().to_string())
}
fn snapshot_version_from_file ( path : impl AsRef < Path > ) -> Result < String > { // Check file size. let file_size = fs :: metadata ( & path ) ? . len ( ) ; if file_size > MAX_SNAPSHOT_VERSION_FILE_SIZE { let error_message = format ! ( " " path as_ref ( ) display ( ) file_size MAX_SNAPSHOT_VERSION_FILE_SIZE ) ; return Err ( get_io_error ( & error_message ) ) ; } // Read snapshot_version from file. let mut snapshot_version = String :: new ( ) ; File :: open ( path ) . and_then ( | mut f | f . read_to_string ( & mut snapshot_version ) ) ? ; Ok ( snapshot_version . trim ( ) . to_string ( ) ) }
Reads the `snapshot_version` from a file.
Reads the ` snapshot_version ` from a file .
path
impl AsRef<Path>