1use charset::{Charset, TableChars};
2
3pub mod charset;
4mod fancy;
5mod padstr;
6
7pub enum Layout {
8 Slim,
9 Fixed(usize),
10 Expandable(usize),
11}
12
13pub enum Overflow {
14 Wrap,
15 Truncate,
16}
17
18pub enum Align {
19 Center,
20 Left,
21 Right,
22}
23
24pub enum TitleAlign {
25 LeftOffset(usize),
26 RightOffset(usize),
27}
28
29pub enum Separator {
30 Single,
31 Double,
32 Custom(char),
33}
34
35pub struct FancyTableOpts {
36 pub title_align: TitleAlign,
37 pub charset: Charset,
38 pub headers_separator: Option<Separator>,
39 pub rows_separator: Option<Separator>,
40 pub max_lines: usize,
41}
42
43pub struct FancyTable<'a, T: AsRef<str>> {
44 width: usize,
45 chars: TableChars,
46 padding: usize,
47 columns: Vec<ColSpec>,
48 headers: Vec<T>,
49 rows_separator: Option<Separator>,
50 headers_separator: Option<Separator>,
51 title: Option<TitleSpec<'a>>,
52}
53
54pub struct FancyTableBuilder<'a, T: AsRef<str>> {
55 padding: usize,
56 max_lines: usize,
57 rows_separator: Option<Separator>,
58 headers_separator: Option<Separator>,
59 charset: Charset,
60 headers: Vec<T>,
61 columns: Vec<ColSpec>,
62 title: Option<&'a str>,
63 title_align: TitleAlign,
64}
65
66struct ColSpec {
67 width: usize,
68 max_lines: usize,
69 align: Align,
70 layout: Layout,
71 overflow: Overflow,
72}
73
74struct TitleSpec<'a> {
75 title: &'a str,
76 align: TitleAlign,
77}