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:
- A
a2a_protocol_types::TaskStatusUpdateEventwith a terminal state is received. - The body ends after an event a stream may end on: a
Message, or a task or status update in a terminal or interrupted state.
It fails (Some(Err(...)), then None) when:
- The body ends anywhere else —
ClientError::IncompleteStream, which carries the last SSEid:to resume from. - A silence bound expires —
ClientError::Timeout. - A protocol or transport error occurs.
§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§
- Event
Stream - An async stream of
StreamResponseevents from an SSE endpoint.