MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_hash_with_length

Function format_hash_with_length

atomic-cli/src/commands/mod.rs:422–429  ·  view source on GitHub ↗

Format a hash for display with custom length. Like [`format_hash`], but allows specifying the truncation length. # Arguments `hash` - The hash to format `length` - Maximum characters to show (0 means no truncation) # Returns A formatted string representation of the hash.

(hash: &Hash, length: usize)

Source from the content-addressed store, hash-verified

420///
421/// A formatted string representation of the hash.
422pub fn format_hash_with_length(hash: &Hash, length: usize) -> String {
423 let base32 = hash.to_base32();
424 if length == 0 || base32.len() <= length {
425 base32
426 } else {
427 base32[..length].to_string()
428 }
429}
430
431/// Format a timestamp for display.
432///

Callers 6

format_defaultMethod · 0.85
format_shortMethod · 0.85
format_onelineMethod · 0.85
format_defaultMethod · 0.85
format_shortMethod · 0.85

Calls 2

to_base32Method · 0.45
lenMethod · 0.45

Tested by 1