langgraph_core_rs/
stream.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value as JsonValue;
3use crate::types::StreamMode;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct StreamPart {
11 pub mode: StreamMode,
13 pub ns: Vec<String>,
15 pub data: JsonValue,
17}
18
19impl StreamPart {
20 pub fn values(ns: Vec<String>, data: JsonValue) -> Self {
21 Self { mode: StreamMode::Values, ns, data }
22 }
23
24 pub fn updates(ns: Vec<String>, data: JsonValue) -> Self {
25 Self { mode: StreamMode::Updates, ns, data }
26 }
27
28 pub fn messages(ns: Vec<String>, data: JsonValue) -> Self {
29 Self { mode: StreamMode::Messages, ns, data }
30 }
31
32 pub fn custom(ns: Vec<String>, data: JsonValue) -> Self {
33 Self { mode: StreamMode::Custom, ns, data }
34 }
35
36 pub fn tasks(ns: Vec<String>, data: JsonValue) -> Self {
37 Self { mode: StreamMode::Tasks, ns, data }
38 }
39
40 pub fn checkpoints(ns: Vec<String>, data: JsonValue) -> Self {
41 Self { mode: StreamMode::Checkpoints, ns, data }
42 }
43
44 pub fn debug(ns: Vec<String>, data: JsonValue) -> Self {
45 Self { mode: StreamMode::Debug, ns, data }
46 }
47}