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

@ -73,19 +73,16 @@ fn decompose(str_in: &str) -> VecDeque<SortingType> {
false
};
use SortingType::*;
use SortingType::{Lexical, Numerical, SemverPrerelease};
if currently_numeric {
if numeric {
return None;
} else {
return Some(
current
.parse::<i64>()
.map(|n| Numerical(n, current.to_owned()))
.unwrap_or_else(|_| Lexical(current.to_owned())),
);
}
return Some(current.parse::<i64>().map_or_else(
|_| Lexical(current.to_owned()),
|n| Numerical(n, current.to_owned()),
));
}
if !(numeric || c == Some(&'-') || c.is_none()) {
@ -124,7 +121,7 @@ fn decompose(str_in: &str) -> VecDeque<SortingType> {
out
}
/// Compare two version strings using FlexVer rules.
/// Compare two version strings using `FlexVer` rules.
///
/// Returns:
/// - `Ordering::Less` if `a` < `b`
@ -141,7 +138,7 @@ pub fn compare(left: &str, right: &str) -> Ordering {
};
for next in iter {
use SortingType::*;
use SortingType::{Numerical, SemverPrerelease};
let current = match next {
// Left ran out first
@ -198,7 +195,7 @@ impl Iterator for VersionComparisonIterator {
}
}
/// FlexVer type for use with standard library traits
/// `FlexVer` type for use with standard library traits
#[derive(Debug, Copy, Clone)]
pub struct FlexVer<'a>(pub &'a str);

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