1mod indent;
4mod max_line_length;
5mod newline;
6
7pub use indent::Indent;
8pub use max_line_length::MaxLineLength;
9pub use newline::NewlineStyle;
10use serde::Deserialize;
11use serde::Serialize;
12
13const SORT_IMPORTS_DEFAULT: bool = true;
15const SORT_INPUTS_DEFAULT: bool = false;
17const TRAILING_COMMAS_DEFAULT: bool = true;
19
20#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
22#[serde(default, deny_unknown_fields)]
23pub struct Config {
24 pub indent: Indent,
26 pub max_line_length: MaxLineLength,
28 pub sort_imports: bool,
30 pub sort_inputs: bool,
32 pub trailing_commas: bool,
34 pub newline_style: NewlineStyle,
36}
37
38impl Default for Config {
39 fn default() -> Self {
40 Self {
41 indent: Indent::default(),
42 max_line_length: MaxLineLength::default(),
43 sort_imports: SORT_IMPORTS_DEFAULT,
44 sort_inputs: SORT_INPUTS_DEFAULT,
45 trailing_commas: TRAILING_COMMAS_DEFAULT,
46 newline_style: NewlineStyle::default(),
47 }
48 }
49}
50
51impl Config {
52 pub fn indent(mut self, indent: Indent) -> Self {
54 self.indent = indent;
55 self
56 }
57
58 pub fn newline_style(mut self, newline_style: NewlineStyle) -> Self {
60 self.newline_style = newline_style;
61 self
62 }
63
64 pub fn max_line_length(mut self, max_line_length: MaxLineLength) -> Self {
66 self.max_line_length = max_line_length;
67 self
68 }
69
70 pub fn sort_imports(mut self, sort_imports: bool) -> Self {
72 self.sort_imports = sort_imports;
73 self
74 }
75
76 pub fn sort_inputs(mut self, sort_inputs: bool) -> Self {
78 self.sort_inputs = sort_inputs;
79 self
80 }
81
82 pub fn trailing_commas(mut self, trailing_commas: bool) -> Self {
84 self.trailing_commas = trailing_commas;
85 self
86 }
87}