systemprompt_models/artifacts/table/
column.rs1use crate::artifacts::types::{Alignment, ColumnType};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
6pub struct Column {
7 pub name: String,
8 #[serde(rename = "column_type")]
9 pub kind: ColumnType,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub label: Option<String>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub width: Option<usize>,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub align: Option<Alignment>,
16}
17
18impl Column {
19 pub fn new(name: impl Into<String>, kind: ColumnType) -> Self {
20 Self {
21 name: name.into(),
22 kind,
23 label: None,
24 width: None,
25 align: None,
26 }
27 }
28
29 pub fn with_header(mut self, header: impl Into<String>) -> Self {
30 self.label = Some(header.into());
31 self
32 }
33
34 pub fn with_label(self, label: impl Into<String>) -> Self {
35 self.with_header(label)
36 }
37
38 pub const fn with_width(mut self, width: usize) -> Self {
39 self.width = Some(width);
40 self
41 }
42
43 pub const fn with_alignment(mut self, align: Alignment) -> Self {
44 self.align = Some(align);
45 self
46 }
47
48 pub fn name(&self) -> &str {
49 &self.name
50 }
51
52 pub const fn column_type(&self) -> ColumnType {
53 self.kind
54 }
55}