pub fn truncate_middle(content: &str, byte_budget: usize) -> StringExpand description
Keep the head and tail of content within byte_budget bytes, replacing
the middle with a marker that states how many bytes were removed. Cuts land
on character boundaries so the result is always valid UTF-8.
ยงExamples
use universal_agent_runtime::uar::runtime::context::truncate::truncate_middle;
let s: String = (0..100).map(|i| format!("{i}\n")).collect();
let t = truncate_middle(&s, 60);
assert!(t.len() <= 60);
assert!(t.starts_with("0\n"));
assert!(t.ends_with("99\n"));