build: bump all dependencies and set MSRV to 1.94; fix build failures

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7d331410864358d30191781d1e6c23f46a6a6964
This commit is contained in:
raf 2026-04-21 17:21:39 +03:00
commit 8b2140c057
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
12 changed files with 248 additions and 196 deletions

View file

@ -10,6 +10,16 @@ use sha2::{Sha256, Sha512};
use crate::error::{PakkerError, Result};
pub fn hash_to_hex(hash: impl AsRef<[u8]>) -> String {
use std::fmt::Write;
let bytes = hash.as_ref();
let mut hex = String::with_capacity(bytes.len() * 2);
for byte in bytes {
write!(hex, "{byte:02x}").unwrap();
}
hex
}
/// Compute SHA1 hash of a file
pub fn compute_sha1<P: AsRef<Path>>(path: P) -> Result<String> {
let file = File::open(path)?;
@ -25,7 +35,7 @@ pub fn compute_sha1<P: AsRef<Path>>(path: P) -> Result<String> {
hasher.update(&buffer[..n]);
}
Ok(format!("{:x}", hasher.finalize()))
Ok(hash_to_hex(hasher.finalize().as_slice()))
}
/// Compute SHA256 hash of a file
@ -43,14 +53,14 @@ pub fn compute_sha256<P: AsRef<Path>>(path: P) -> Result<String> {
hasher.update(&buffer[..n]);
}
Ok(format!("{:x}", hasher.finalize()))
Ok(hash_to_hex(hasher.finalize().as_slice()))
}
/// Compute SHA256 hash of byte data
pub fn compute_sha256_bytes(data: &[u8]) -> String {
let mut hasher = Sha256::new();
hasher.update(data);
format!("{:x}", hasher.finalize())
hash_to_hex(hasher.finalize().as_slice())
}
/// Compute SHA512 hash of a file
@ -68,7 +78,7 @@ pub fn compute_sha512<P: AsRef<Path>>(path: P) -> Result<String> {
hasher.update(&buffer[..n]);
}
Ok(format!("{:x}", hasher.finalize()))
Ok(hash_to_hex(hasher.finalize().as_slice()))
}
/// Compute MD5 hash of a file
@ -86,7 +96,12 @@ pub fn compute_md5<P: AsRef<Path>>(path: P) -> Result<String> {
hasher.update(&buffer[..n]);
}
Ok(format!("{:x}", hasher.finalize()))
let hash = hasher.finalize();
let mut hex = String::with_capacity(hash.len() * 2);
for byte in hash {
std::fmt::write(&mut hex, format_args!("{byte:02x}")).unwrap();
}
Ok(hex)
}
/// Verify a file's hash against expected value