chore: bump deps; fix clippy lints & cleanup
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4c4815ad145650a07f108614034d2e996a6a6964
This commit is contained in:
parent
c535650f45
commit
cd1161ee5d
41 changed files with 1283 additions and 740 deletions
|
|
@ -4,6 +4,19 @@ use crate::{error::Result, model::ContentHash};
|
|||
|
||||
const BUFFER_SIZE: usize = 65536;
|
||||
|
||||
/// Computes the BLAKE3 hash of a file asynchronously.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Path to the file to hash
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The content hash
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns I/O errors or task execution errors
|
||||
pub async fn compute_file_hash(path: &Path) -> Result<ContentHash> {
|
||||
let path = path.to_path_buf();
|
||||
let hash = tokio::task::spawn_blocking(move || -> Result<ContentHash> {
|
||||
|
|
@ -24,6 +37,7 @@ pub async fn compute_file_hash(path: &Path) -> Result<ContentHash> {
|
|||
Ok(hash)
|
||||
}
|
||||
|
||||
/// Computes the BLAKE3 hash of a byte slice synchronously.
|
||||
pub fn compute_hash_sync(data: &[u8]) -> ContentHash {
|
||||
let hash = blake3::hash(data);
|
||||
ContentHash::new(hash.to_hex().to_string())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue