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)
| 523 | /// println!("{}", format_hash(&hash, true)); // "ABCDEFGHIJKLMNOP" |
| 524 | /// ``` |
| 525 | pub fn format_hash(hash: &Hash, full: bool) -> String { |
| 526 | let base32 = hash.to_base32(); |
| 527 | if full || base32.len() <= DEFAULT_HASH_LENGTH { |
| 528 | base32 |
| 529 | } else { |
| 530 | base32[..DEFAULT_HASH_LENGTH].to_string() |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /// Format a hash for display with custom length. |
| 535 | /// |