systemprompt_models/artifacts/dashboard/section_data/
list.rs1use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
10pub struct ListSectionData {
11 pub lists: Vec<ItemList>,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
15pub struct ItemList {
16 pub title: String,
17 pub items: Vec<ListItem>,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
21pub struct ListItem {
22 pub rank: i32,
23 pub label: String,
24 pub value: String,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub badge: Option<String>,
27}
28
29impl ListSectionData {
30 pub const fn new(lists: Vec<ItemList>) -> Self {
31 Self { lists }
32 }
33}
34
35impl ItemList {
36 pub fn new(title: impl Into<String>, items: Vec<ListItem>) -> Self {
37 Self {
38 title: title.into(),
39 items,
40 }
41 }
42}
43
44impl ListItem {
45 pub fn new(rank: i32, label: impl Into<String>, value: impl Into<String>) -> Self {
46 Self {
47 rank,
48 label: label.into(),
49 value: value.into(),
50 badge: None,
51 }
52 }
53
54 pub fn with_badge(mut self, badge: impl Into<String>) -> Self {
55 self.badge = Some(badge.into());
56 self
57 }
58}