boarddown_schema/
column.rs1use serde::{Deserialize, Serialize};
2use ts_rs::TS;
3
4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
5#[ts(export)]
6pub struct Column {
7 pub name: String,
8 pub order: usize,
9 pub wip_limit: Option<usize>,
10}
11
12impl Column {
13 pub fn new(name: impl Into<String>) -> Self {
14 Self {
15 name: name.into(),
16 order: 0,
17 wip_limit: None,
18 }
19 }
20
21 pub fn with_order(mut self, order: usize) -> Self {
22 self.order = order;
23 self
24 }
25
26 pub fn with_wip_limit(mut self, limit: usize) -> Self {
27 self.wip_limit = Some(limit);
28 self
29 }
30}
31
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
33#[ts(export)]
34pub enum ColumnRef {
35 Name(String),
36 Index(usize),
37}
38
39impl From<&str> for ColumnRef {
40 fn from(s: &str) -> Self {
41 ColumnRef::Name(s.to_string())
42 }
43}
44
45impl From<String> for ColumnRef {
46 fn from(s: String) -> Self {
47 ColumnRef::Name(s)
48 }
49}
50
51impl From<usize> for ColumnRef {
52 fn from(i: usize) -> Self {
53 ColumnRef::Index(i)
54 }
55}
56
57impl std::fmt::Display for ColumnRef {
58 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59 match self {
60 ColumnRef::Name(name) => write!(f, "{}", name),
61 ColumnRef::Index(idx) => write!(f, "{}", idx),
62 }
63 }
64}