mod indent;
mod max_line_length;
mod newline;
pub use indent::Indent;
pub use max_line_length::MaxLineLength;
pub use newline::NewlineStyle;
use serde::Deserialize;
use serde::Serialize;
const SORT_IMPORTS_DEFAULT: bool = true;
const SORT_INPUTS_DEFAULT: bool = false;
const TRAILING_COMMAS_DEFAULT: bool = true;
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct Config {
pub indent: Indent,
pub max_line_length: MaxLineLength,
pub sort_imports: bool,
pub sort_inputs: bool,
pub trailing_commas: bool,
pub newline_style: NewlineStyle,
}
impl Default for Config {
fn default() -> Self {
Self {
indent: Indent::default(),
max_line_length: MaxLineLength::default(),
sort_imports: SORT_IMPORTS_DEFAULT,
sort_inputs: SORT_INPUTS_DEFAULT,
trailing_commas: TRAILING_COMMAS_DEFAULT,
newline_style: NewlineStyle::default(),
}
}
}
impl Config {
pub fn indent(mut self, indent: Indent) -> Self {
self.indent = indent;
self
}
pub fn newline_style(mut self, newline_style: NewlineStyle) -> Self {
self.newline_style = newline_style;
self
}
pub fn max_line_length(mut self, max_line_length: MaxLineLength) -> Self {
self.max_line_length = max_line_length;
self
}
pub fn sort_imports(mut self, sort_imports: bool) -> Self {
self.sort_imports = sort_imports;
self
}
pub fn sort_inputs(mut self, sort_inputs: bool) -> Self {
self.sort_inputs = sort_inputs;
self
}
pub fn trailing_commas(mut self, trailing_commas: bool) -> Self {
self.trailing_commas = trailing_commas;
self
}
}