async fn validate_sha256(file: &mut File, sha: &str) -> Result<()> {
    let mut hasher = AsyncSha256::new();
    tokio::io::copy(file, &mut hasher).await?;
    let hasher = match hasher.into_inner() {
        Ok(h) => h,
        Err(_) => {
            return Err(ProviderError::Io(std::io::Error::new(
                std::io::ErrorKind::Other,
                "data write corruption, mutex poisoned",
            )))
        }
    };
    let result = hasher.finalize();

    if format!("{:x}", result) != sha {
        return Err(ProviderError::DigestMismatch);
    }

    Ok(())
}
/// Validate that the File path matches the given SHA256
Validate that the File path matches the given SHA256
Validate that the File path matches the given SHA256
async fn validate_sha256(file: &mut File, sha: &str) -> Result<()> {
    let mut hasher = AsyncSha256::new();
    tokio::io::copy(file, &mut hasher).await?;
    let hasher = match hasher.into_inner() {
        Ok(h) => h,
        Err(_) => {
            return Err(ProviderError::Io(std::io::Error::new(
                std::io::ErrorKind::Other,
                "data write corruption, mutex poisoned",
            )))
        }
    };
    let result = hasher.finalize();
    if format!("{:x}", result) != sha {
        return Err(ProviderError::DigestMismatch);
    }
    Ok(())
}
async fn validate_sha256 ( file : & mut File , sha : & str ) -> Result < ( ) > { let mut hasher = AsyncSha256 :: new ( ) ; tokio :: io :: copy ( file , & mut hasher ) . await ? ; let hasher = match hasher . into_inner ( ) { Ok ( h ) => h , Err ( _ ) => { return Err ( ProviderError :: Io ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , " " , ) ) ) } } ; let result = hasher . finalize ( ) ; if format ! ( " " result ) != sha { return Err ( ProviderError :: DigestMismatch ) ; } Ok ( ( ) ) }
Validate that the File path matches the given SHA256
Validate that the File path matches the given SHA256
file
&mut File
sha
&str
file
&mut File
sha
&str