pub struct StreamEvent {
pub event_type: StreamEventType,
pub timestamp: u64,
pub content: Option<String>,
pub tool_call: Option<ToolCallData>,
pub metadata: HashMap<String, String>,
pub error: Option<String>,
pub is_reasoning: bool,
pub agent_id: Option<String>,
pub session_id: Option<String>,
pub run_id: Option<String>,
}Expand description
A single streaming event emitted during LLM response streaming.
Fields§
§event_type: StreamEventTypeEvent type
timestamp: u64Timestamp (milliseconds since epoch)
content: Option<String>Text content for DeltaText events
tool_call: Option<ToolCallData>Tool call data for DeltaToolCall events
metadata: HashMap<String, String>Additional metadata
error: Option<String>Error message for Error events
is_reasoning: boolWhether this is reasoning/thinking content
agent_id: Option<String>Agent ID for multi-agent scenarios
session_id: Option<String>Session ID for tracking
run_id: Option<String>Run ID for correlation
Implementations§
Source§impl StreamEvent
impl StreamEvent
Sourcepub fn new(event_type: StreamEventType) -> Self
pub fn new(event_type: StreamEventType) -> Self
Create a new stream event
Sourcepub fn tool_call(self, tool_call: ToolCallData) -> Self
pub fn tool_call(self, tool_call: ToolCallData) -> Self
Set tool call
Sourcepub fn session_id(self, id: impl Into<String>) -> Self
pub fn session_id(self, id: impl Into<String>) -> Self
Set session ID
Sourcepub fn request_start() -> Self
pub fn request_start() -> Self
Create a request start event
Sourcepub fn first_token(content: impl Into<String>) -> Self
pub fn first_token(content: impl Into<String>) -> Self
Create a first token event
Sourcepub fn delta_text(content: impl Into<String>) -> Self
pub fn delta_text(content: impl Into<String>) -> Self
Create a delta text event
Sourcepub fn stream_end() -> Self
pub fn stream_end() -> Self
Create a stream end event
Sourcepub fn error_event(message: impl Into<String>) -> Self
pub fn error_event(message: impl Into<String>) -> Self
Create an error event
Trait Implementations§
Source§impl Clone for StreamEvent
impl Clone for StreamEvent
Source§fn clone(&self) -> StreamEvent
fn clone(&self) -> StreamEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StreamEvent
impl Debug for StreamEvent
Source§impl<'de> Deserialize<'de> for StreamEvent
impl<'de> Deserialize<'de> for StreamEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StreamEvent
impl RefUnwindSafe for StreamEvent
impl Send for StreamEvent
impl Sync for StreamEvent
impl Unpin for StreamEvent
impl UnwindSafe for StreamEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more