pub struct StreamSegment {
pub stream_id: String,
pub seq: u64,
pub final_segment: bool,
pub schema: String,
pub payload: Value,
}Expand description
A segment within a continuously ordered data stream.
Typical use cases include AI token streams, file transfers, audio/video frames, etc.
All messages belonging to the same stream share a stream_id and are ordered by seq.
Fields§
§stream_id: StringStream identifier — all segments of the same stream share this value.
Generated by the sender when the stream starts (typically a ULID).
seq: u64Monotonically increasing sequence number within the stream (starting from 0).
The receiver uses this to order segments and detect any missing ones.
final_segment: boolWhether this is the final segment.
true indicates the stream has ended; the receiver should complete stream processing
and clean up associated state.
schema: StringSchema identifier, formatted as {domain}.{name}@{major}.{minor}.
Defines the structure of payload, e.g. "ai.token@1.0", "file.chunk@1.0".
payload: ValueSegment payload in JSON format.
For AI token streams, this is typically {"text": "..."}.
For file transfers, this is typically a Base64-encoded data chunk.
Trait Implementations§
Source§impl Clone for StreamSegment
impl Clone for StreamSegment
Source§fn clone(&self) -> StreamSegment
fn clone(&self) -> StreamSegment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more