1use serde::{Deserialize, Serialize};
4
5use super::program::VariableDecl;
6use super::span::Span;
7use super::statements::Statement;
8use super::time::Timeframe;
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct StreamDef {
13 pub name: String,
14 pub name_span: Span,
15 pub config: StreamConfig,
16 pub state: Vec<VariableDecl>,
17 pub on_connect: Option<Vec<Statement>>,
18 pub on_disconnect: Option<Vec<Statement>>,
19 pub on_event: Option<StreamOnEvent>,
20 pub on_window: Option<StreamOnWindow>,
21 pub on_error: Option<StreamOnError>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct StreamConfig {
27 pub provider: String,
28 pub symbols: Vec<String>,
29 pub timeframes: Vec<Timeframe>,
30 pub buffer_size: Option<u32>,
31 pub reconnect: Option<bool>,
32 pub reconnect_delay: Option<f64>, }
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct StreamOnEvent {
38 pub event_param: String,
39 pub body: Vec<Statement>,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct StreamOnWindow {
45 pub key_param: String,
46 pub window_param: String,
47 pub body: Vec<Statement>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct StreamOnError {
53 pub error_param: String,
54 pub body: Vec<Statement>,
55}