#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ForceStyle {
None,
Inline,
Multiline,
}
#[derive(Debug, Clone)]
pub struct FormatOptions {
pub indent: &'static str,
pub max_width: usize,
pub min_inline_width: usize,
pub inline_object_threshold: usize,
pub inline_sequence_threshold: usize,
pub heredoc_line_threshold: usize,
pub force_style: ForceStyle,
}
impl Default for FormatOptions {
fn default() -> Self {
Self {
indent: " ",
max_width: 80,
min_inline_width: 30,
inline_object_threshold: 4,
inline_sequence_threshold: 8,
heredoc_line_threshold: 2,
force_style: ForceStyle::None,
}
}
}
impl FormatOptions {
pub fn new() -> Self {
Self::default()
}
pub fn multiline(mut self) -> Self {
self.force_style = ForceStyle::Multiline;
self
}
pub fn inline(mut self) -> Self {
self.force_style = ForceStyle::Inline;
self
}
pub fn indent(mut self, indent: &'static str) -> Self {
self.indent = indent;
self
}
pub fn max_width(mut self, width: usize) -> Self {
self.max_width = width;
self
}
}