Skip to main content

sse_event

Function sse_event 

Source
pub fn sse_event(evt: &NormalizedEvent) -> String
Expand description

Convert a NormalizedEvent to an SSE-formatted string.

The output follows the Server-Sent Events specification with both an event: line (for EventSource listeners) and a data: line containing the JSON payload.

ยงExample

use universal_agent_runtime::normalized::{NormalizedEvent, sse_event};

let event = NormalizedEvent::Done;
let sse = sse_event(&event);
assert!(sse.contains("event: done"));