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.

The stream terminates 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.state);
            if ev.r#final { break; }
        }
        StreamResponse::ArtifactUpdate(ev) => {
            println!("Artifact: {:?}", ev.artifact);
        }
        _ => {}
    }
}

Structs§

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