pub struct AssistantMessageEventStream { /* private fields */ }Expand description
The consumer side of an AssistantMessageEventStream. Mirrors the
AssistantMessageEventStream class: an async iterator over
AssistantMessageEvent plus a result() future.
Cloneable so multiple subscribers can drain independently via
tokio::sync::broadcast at a higher layer; the raw channel is SPSC but the
agent loop wraps it so that’s rarely needed.
Implementations§
Source§impl AssistantMessageEventStream
impl AssistantMessageEventStream
Sourcepub async fn next(&mut self) -> Option<AssistantMessageEvent>
pub async fn next(&mut self) -> Option<AssistantMessageEvent>
Asynchronously pull the next event, or None once the stream is
exhausted (after the terminal Done/Error). Mirrors the TS
async-iterator’s next().
Sourcepub async fn result(self) -> Result<AssistantMessage, RecvError>
pub async fn result(self) -> Result<AssistantMessage, RecvError>
Resolve to the final AssistantMessage — the message carried by the
terminal Done (success) or Error (failure). Mirrors TS result().
Cancellation / producer-drop surfaces as a RecvError, mapped to a
terminal error message. A well-behaved producer always sends one
terminal event, so the happy path never hits that branch.
Sourcepub fn split(
self,
) -> (UnboundedReceiver<AssistantMessageEvent>, Receiver<AssistantMessage>)
pub fn split( self, ) -> (UnboundedReceiver<AssistantMessageEvent>, Receiver<AssistantMessage>)
Borrow both channels for ad-hoc awaiting (used by the agent loop when it needs to race the event queue against a cancellation token).