Expand description
Wire encoding for the event stream.
EventStreamFormatter is the abstraction a transport implements.
sse::SseFormatter is the one every AG-UI implementation supports.
use ag_ui::{Event, EventStreamFormatter, SseFormatter};
let formatter = SseFormatter::new();
let bytes = formatter.encode(&Event::text_message_end("msg-1")).unwrap();
assert_eq!(
String::from_utf8(bytes).unwrap(),
"data: {\"type\":\"TEXT_MESSAGE_END\",\"messageId\":\"msg-1\"}\n\n"
);Modules§
Constants§
- PROTOBUF_
MEDIA_ TYPE - Media type of the AG-UI binary stream, as defined by the upstream
@ag-ui/protopackage. - SSE_
MEDIA_ TYPE - Media type of a Server-Sent Events stream.
Traits§
- Event
Stream Formatter - Turns events into the bytes a transport puts on the wire.
Functions§
- media_
type - Picks the media type to answer an
Acceptheader with. - supported_
media_ types - The media types this build can emit, most preferred first.