Skip to main content

Module formatting

Module formatting 

Source
Expand description

Unified formatting utilities for UI and logging

Functionsยง

format_size
Format file size in human-readable form (KB, MB, GB, etc.)
indent_block
Indent a block of text with the given prefix
truncate_byte_budget
Truncate a string so that the retained prefix is at most max_bytes bytes, rounded down to the nearest UTF-8 char boundary. Returns the truncated prefix with suffix appended, or the original string when it already fits.
truncate_text
Truncate text to a maximum length (in chars) with an optional ellipsis.