Truncate a string for display in log messages and UI. Adds "..." suffix if truncated. Used for intent/outcome summaries in log output.
(s: &str, max_len: usize)
| 340 | /// Adds "..." suffix if truncated. Used for intent/outcome summaries |
| 341 | /// in log output. |
| 342 | pub fn truncate_for_display(s: &str, max_len: usize) -> String { |
| 343 | if s.len() <= max_len { |
| 344 | return s.to_string(); |
| 345 | } |
| 346 | let truncated: String = s.chars().take(max_len.saturating_sub(3)).collect(); |
| 347 | format!("{}...", truncated) |
| 348 | } |
| 349 | |
| 350 | /// Truncate a string for inclusion in error messages. |
| 351 | pub(crate) fn truncate_for_error(s: &str, max_len: usize) -> String { |