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)
| 423 | /// println!("{}", format_hash(&hash, true)); // "ABCDEFGHIJKLMNOP" |
| 424 | /// ``` |
| 425 | pub fn format_hash(hash: &Hash, full: bool) -> String { |
| 426 | let base32 = hash.to_base32(); |
| 427 | if full || base32.len() <= DEFAULT_HASH_LENGTH { |
| 428 | base32 |
| 429 | } else { |
| 430 | base32[..DEFAULT_HASH_LENGTH].to_string() |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /// Format a hash for display with custom length. |
| 435 | /// |