1mod indent;
4mod max_line_length;
5
6pub use indent::Indent;
7pub use max_line_length::MaxLineLength;
8use serde::Deserialize;
9use serde::Serialize;
10
11const SORT_IMPORTS_DEFAULT: bool = true;
13const SORT_INPUTS_DEFAULT: bool = false;
15const TRAILING_COMMAS_DEFAULT: bool = true;
17
18#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
20#[serde(default, deny_unknown_fields)]
21pub struct Config {
22 pub indent: Indent,
24 pub max_line_length: MaxLineLength,
26 pub sort_imports: bool,
28 pub sort_inputs: bool,
30 pub trailing_commas: bool,
32}
33
34impl Default for Config {
35 fn default() -> Self {
36 Self {
37 indent: Indent::default(),
38 max_line_length: MaxLineLength::default(),
39 sort_imports: SORT_IMPORTS_DEFAULT,
40 sort_inputs: SORT_INPUTS_DEFAULT,
41 trailing_commas: TRAILING_COMMAS_DEFAULT,
42 }
43 }
44}
45
46impl Config {
47 pub fn indent(mut self, indent: Indent) -> Self {
49 self.indent = indent;
50 self
51 }
52
53 pub fn max_line_length(mut self, max_line_length: MaxLineLength) -> Self {
55 self.max_line_length = max_line_length;
56 self
57 }
58
59 pub fn sort_imports(mut self, sort_imports: bool) -> Self {
61 self.sort_imports = sort_imports;
62 self
63 }
64
65 pub fn sort_inputs(mut self, sort_inputs: bool) -> Self {
67 self.sort_inputs = sort_inputs;
68 self
69 }
70
71 pub fn trailing_commas(mut self, trailing_commas: bool) -> Self {
73 self.trailing_commas = trailing_commas;
74 self
75 }
76}