Expand description
UTF-8-safe text truncation for context render and compression.
All byte-index cuts must land on char boundaries — slicing mid-scalar
panics in debug builds and produces invalid strings in release.
Functions§
- proportional_
byte_ keep - Proportional byte budget for render-time truncation: keep
remainingoftotalestimated tokens from a message whose content istextbytes long. - truncate_
bytes_ at_ char_ boundary - Return the longest prefix of
textwith at mostmax_bytesUTF-8 bytes, never splitting a scalar value. - truncate_
with_ suffix - Truncate
textto at mostmax_bytesbytes on a char boundary and appendsuffix.