Skip to main content

systemprompt_models/artifacts/dashboard/section_data/
text.rs

1//! Free-text and timeline section payloads.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
10pub struct TextSectionData {
11    pub text: String,
12}
13
14impl TextSectionData {
15    pub fn new(text: impl Into<String>) -> Self {
16        Self { text: text.into() }
17    }
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
21pub struct TimelineSectionData {
22    pub events: Vec<TimelineEvent>,
23}
24
25impl TimelineSectionData {
26    pub const fn new(events: Vec<TimelineEvent>) -> Self {
27        Self { events }
28    }
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
32pub struct TimelineEvent {
33    pub timestamp: String,
34    pub label: String,
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub description: Option<String>,
37}
38
39impl TimelineEvent {
40    pub fn new(timestamp: impl Into<String>, label: impl Into<String>) -> Self {
41        Self {
42            timestamp: timestamp.into(),
43            label: label.into(),
44            description: None,
45        }
46    }
47
48    pub fn with_description(mut self, description: impl Into<String>) -> Self {
49        self.description = Some(description.into());
50        self
51    }
52}