devimg-core 0.1.15

Core image pipeline logic for devimg
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::fs;
use std::path::Path;

use crate::{DevimgError, Result};

pub fn hash_bytes(bytes: &[u8]) -> String {
    format!("blake3:{}", blake3::hash(bytes).to_hex())
}

pub fn hash_file(path: &Path) -> Result<String> {
    let bytes = fs::read(path).map_err(|source| DevimgError::io(path, source))?;
    Ok(hash_bytes(&bytes))
}