diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/hash.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
Diffstat (limited to 'src/hash.rs')
| -rw-r--r-- | src/hash.rs | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/hash.rs b/src/hash.rs index 70c3791..f638542 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -13,15 +13,11 @@ pub fn hex_str(s: &str) -> String { hex(s.as_bytes()) } -/// First `n` hex chars — enough for display, not for identity. pub fn short(bytes: &[u8], n: usize) -> String { let h = hex(bytes); h[..n.min(h.len())].to_string() } -/// Stream-hash a reader, optionally teeing every byte into `sink` — so a -/// download can be hashed into the source cache without paying for the -/// bandwidth twice (§5.3). pub fn digest_reader<R: Read>(mut r: R, mut sink: Option<&mut dyn Write>) -> io::Result<(String, u64)> { let mut h = Sha256::new(); let mut buf = vec![0u8; 64 * 1024]; @@ -46,9 +42,6 @@ pub fn digest_file(path: &std::path::Path) -> io::Result<(String, u64)> { digest_reader(&mut br, None) } -/// This is `recipe_hash` (DESIGN.md §3): a digest over *every* file in the AUR -/// snapshot tree, because a patch shipped in the AUR repo is part of the recipe -/// and is a classic silent-change vector. pub fn recipe_hash(entries: &[(String, String)]) -> String { let mut sorted: Vec<&(String, String)> = entries.iter().collect(); sorted.sort_unstable_by(|a, b| a.0.cmp(&b.0)); @@ -62,12 +55,6 @@ pub fn recipe_hash(entries: &[(String, String)]) -> String { hex::encode(h.finalize()) } -/// Serialize to canonical JSON: compact, object keys sorted, so equal values always -/// produce equal bytes. The value is routed through `serde_json::Value` because a -/// struct otherwise serializes in field declaration order. -/// -/// A serialization failure is an error, not `"{}"`: this is the function behind -/// `Identity::hash` (M-2). pub fn canonical_json<T: serde::Serialize>(v: &T) -> Result<String, serde_json::Error> { serde_json::to_string(&serde_json::to_value(v)?) } |
