Skip to main content

SseFormat

Trait SseFormat 

Source
pub trait SseFormat: Send + Sync {
    // Required methods
    fn format(&self, event: &EventEnvelope) -> Vec<SseFrame>;
    fn done_frame(&self) -> Option<SseFrame>;
    fn extra_headers(&self) -> Vec<(String, String)>;
    fn name(&self) -> &str;
}
Expand description

Trait for formatting EventEnvelopes into SSE frames for a given wire protocol (OpenAI, Anthropic, Vercel AI SDK, or native Lago format).

Required Methods§

Source

fn format(&self, event: &EventEnvelope) -> Vec<SseFrame>

Convert an event envelope into zero or more SSE frames.

Returning an empty vec means the event is filtered out (not relevant to this format).

Source

fn done_frame(&self) -> Option<SseFrame>

An optional “done” frame to send when the stream terminates.

Source

fn extra_headers(&self) -> Vec<(String, String)>

Extra HTTP headers to include in the SSE response (e.g. Vercel’s x-vercel-ai-data-stream header).

Source

fn name(&self) -> &str

Human-readable name of this format (for logging).

Implementors§