Format a hash for display. By default, hashes are truncated to [`DEFAULT_HASH_LENGTH`] characters for readability. Use `full = true` to show the complete hash. # Arguments `hash` - The hash to format `full` - Whether to show the full hash or truncate it # Returns A formatted string representation of the hash. # Example ```rust,ignore let hash = Hash::from_base32(b"ABCDEFGHIJKLMNOP").unwrap(
(hash: &Hash, full: bool)
| 393 | /// println!("{}", format_hash(&hash, true)); // "ABCDEFGHIJKLMNOP" |
| 394 | /// ``` |
| 395 | pub fn format_hash(hash: &Hash, full: bool) -> String { |
| 396 | let base32 = hash.to_base32(); |
| 397 | if full || base32.len() <= DEFAULT_HASH_LENGTH { |
| 398 | base32 |
| 399 | } else { |
| 400 | base32[..DEFAULT_HASH_LENGTH].to_string() |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /// Format a hash for display with custom length. |
| 405 | /// |