Identify the exact stored Vault revision (entry type, frontmatter, and body — not only the body content hash).
(entry: &VaultEntry)
| 314 | /// Identify the exact stored Vault revision (entry type, frontmatter, |
| 315 | /// and body — not only the body content hash). |
| 316 | fn vault_entry_revision_hash(entry: &VaultEntry) -> String { |
| 317 | fn append_revision_field(hasher: &mut Hasher, value: &[u8]) { |
| 318 | hasher.update(&(value.len() as u64).to_be_bytes()); |
| 319 | hasher.update(value); |
| 320 | } |
| 321 | let mut hasher = Hasher::new(); |
| 322 | hasher.update(b"atomic-vault-revision-v1"); |
| 323 | append_revision_field(&mut hasher, entry.entry_type.as_str().as_bytes()); |
| 324 | append_revision_field(&mut hasher, entry.frontmatter_json.as_bytes()); |
| 325 | append_revision_field(&mut hasher, &entry.content_bytes); |
| 326 | hasher.finalize().to_base32() |
| 327 | } |
| 328 | |
| 329 | /// Truncate to at most `max_chars` characters on a char boundary. |
| 330 | fn truncate_chars(value: &str, max_chars: usize) -> String { |
no test coverage detected