Skip to main content

Module event_stream

Module event_stream 

Source
Expand description

Async SSE event stream with typed deserialization.

EventStream provides an async next() iterator over a2a_protocol_types::StreamResponse events received via Server-Sent Events, and is a futures_core::Stream of the same events.

The stream finishes (None) when:

It fails (Some(Err(...)), then None) when:

§Example

let mut stream = client.stream_message(params).await?;
while let Some(event) = stream.next().await {
    match event? {
        StreamResponse::StatusUpdate(ev) => {
            println!("State: {:?}", ev.status.state);
            if ev.status.state.is_terminal() { break; }
        }
        StreamResponse::ArtifactUpdate(ev) => {
            println!("Artifact: {:?}", ev.artifact);
        }
        _ => {}
    }
}

Structs§

EventStream
An async stream of StreamResponse events from an SSE endpoint.