Skip to main content

preview

Function preview 

Source
pub fn preview(s: &str, max: usize) -> String
Expand description

Truncate a string to at most max characters, appending an ellipsis marker when truncation occurred. Operates on chars (not bytes) so multi-byte characters are not split.

Why: Event payloads should be human-readable previews; raw multi-KB agent outputs would saturate the broadcast channel and overwhelm the SSE stream. Centralising preview construction keeps emit sites tidy. What: Returns s unchanged when shorter than max; otherwise returns the first max chars plus a Unicode horizontal ellipsis.