1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
8#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
9pub struct ColumnSpec {
10 pub template_raw: String,
11 pub template_normalized: String,
12 pub column_align: Vec<ColumnAlign>,
13 pub column_width: Vec<String>,
14 pub column_spacing: Vec<String>,
15 pub column_lines: Vec<LineStyle>,
16 pub frame: Vec<FrameLine>,
17 pub column_start: Vec<String>,
18 pub column_end: Vec<String>,
19 pub column_extra: Vec<bool>,
20 pub row_align: Vec<Option<RowAlign>>,
21 pub array_padding: Option<ArrayPadding>,
22}
23
24impl ColumnSpec {
25 pub fn new(template_raw: String, template_normalized: String) -> Self {
26 ColumnSpec {
27 template_raw,
28 template_normalized,
29 column_align: Vec::new(),
30 column_width: Vec::new(),
31 column_spacing: Vec::new(),
32 column_lines: Vec::new(),
33 frame: Vec::new(),
34 column_start: Vec::new(),
35 column_end: Vec::new(),
36 column_extra: Vec::new(),
37 row_align: Vec::new(),
38 array_padding: None,
39 }
40 }
41}
42
43impl std::fmt::Display for ColumnSpec {
44 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45 write!(f, "{}", self.template_normalized)
46 }
47}
48
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
50#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
51pub enum ColumnAlign {
52 Left,
53 Center,
54 Right,
55 Empty,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
59#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
60pub enum LineStyle {
61 None,
62 Solid,
63 Dashed,
64}
65
66#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
67#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
68pub enum FrameSide {
69 Left,
70 Right,
71}
72
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
75pub struct FrameLine {
76 pub side: FrameSide,
77 pub style: LineStyle,
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
81#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
82pub enum VerticalAlign {
83 Top,
84 Middle,
85 Bottom,
86}
87
88#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
89#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
90pub struct RowAlign {
91 pub vertical: VerticalAlign,
92 pub width: String,
93 pub align: ColumnAlign,
94}
95
96#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
97#[cfg_attr(feature = "tsify", derive(tsify_next::Tsify))]
98pub struct ArrayPadding {
99 pub left: String,
100 pub right: String,
101}