Skip to main content

relux_runtime/observe/structured/
buffer.rs

1use std::time::Duration;
2
3use serde::Deserialize;
4use serde::Serialize;
5use ts_rs::TS;
6
7use super::event::EventSeq;
8
9#[derive(Debug, Clone, Serialize, Deserialize, TS)]
10#[cfg_attr(
11    feature = "ts-export",
12    ts(export, export_to = "../../../viewer/src/types/")
13)]
14pub struct BufferEvent {
15    pub seq: EventSeq,
16    #[serde(with = "super::ts_duration_ms")]
17    #[ts(as = "f64")]
18    pub ts: Duration,
19    pub shell: String,
20    /// Stable identity for the shell. Buffer events always have a shell.
21    pub shell_marker: String,
22    #[serde(flatten)]
23    pub kind: BufferEventKind,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize, TS)]
27#[cfg_attr(
28    feature = "ts-export",
29    ts(export, export_to = "../../../viewer/src/types/")
30)]
31#[serde(tag = "kind", rename_all = "kebab-case")]
32pub enum BufferEventKind {
33    Grew {
34        data: String,
35    },
36    Matched {
37        before: String,
38        matched: String,
39        after: String,
40    },
41    Reset {
42        consumed: String,
43    },
44}