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)
| 399 | /// println!("{}", format_hash(&hash, true)); // "ABCDEFGHIJKLMNOP" |
| 400 | /// ``` |
| 401 | pub fn format_hash(hash: &Hash, full: bool) -> String { |
| 402 | let base32 = hash.to_base32(); |
| 403 | if full || base32.len() <= DEFAULT_HASH_LENGTH { |
| 404 | base32 |
| 405 | } else { |
| 406 | base32[..DEFAULT_HASH_LENGTH].to_string() |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | /// Format a hash for display with custom length. |
| 411 | /// |