refactor(svc): tidy the rust services and build tooling (#2735)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-13 17:38:32 +02:00
1 parent 33737e0f79
commit 6af33c7188
41 files changed
+863 -1304

No files matched your search

+15 -1
View File
@@ -2,8 +2,9 @@
use anyhow::{Context, Result};
use serde::Serialize;
use sha2::{Digest, Sha256};
use std::fs;
use std::io;
use std::io::{self, Read};
use std::path::Path;
pub(crate) fn remove_file_if_exists(path: &Path) -> Result<()> {
@@ -32,6 +33,19 @@ pub(crate) fn write_json_pretty<T: Serialize + ?Sized>(path: &Path, value: &T) -
fs::write(path, bytes).with_context(|| format!("Failed to write {}", path.display()))
}
pub(crate) fn sha256_reader(mut reader: impl Read) -> io::Result<String> {
let mut hasher = Sha256::new();
let mut buffer = [0u8; 64 * 1024];
loop {
let read = reader.read(&mut buffer)?;
if read == 0 {
break;
}
hasher.update(&buffer[..read]);
}
Ok(hex::encode(hasher.finalize()))
}
#[cfg(test)]
mod tests {
use super::*;