#[non_exhaustive]pub struct FormatOptions {
pub line_width: usize,
pub indent_width: usize,
pub uppercase_keywords: bool,
pub keyword_case: KeywordCase,
pub line_ending: LineEnding,
pub dialect: Dialect,
}Expand description
Options controlling formatting. Opinionated and intentionally small.
This type is #[non_exhaustive]: future releases may add knobs without it being a breaking
change. Consequently, callers in other crates cannot build it with a struct literal. Start from
FormatOptions::default and adjust it through the with_* builder methods instead:
use sql_dialect_fmt_formatter::FormatOptions;
let options = FormatOptions::default()
.with_line_width(80)
.with_indent_width(2)
.with_keyword_case(sql_dialect_fmt_formatter::KeywordCase::Preserve);
assert_eq!(options.line_width, 80);
assert_eq!(options.indent_width, 2);
assert_eq!(options.keyword_case, sql_dialect_fmt_formatter::KeywordCase::Preserve);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.line_width: usizeTarget line width the printer keeps within where it can.
indent_width: usizeSpaces per indentation level.
uppercase_keywords: boolUpper-case SQL keywords.
Kept for 1.x source compatibility. New code should use FormatOptions::keyword_case or
FormatOptions::with_keyword_case. When this is set to false and keyword_case is still
KeywordCase::Upper, the formatter treats it as KeywordCase::Preserve.
keyword_case: KeywordCaseKeyword casing policy.
line_ending: LineEndingOutput line-ending policy.
dialect: DialectThe SQL dialect to parse and format. Defaults to Dialect::Snowflake.
Implementations§
Source§impl FormatOptions
impl FormatOptions
Sourcepub fn with_line_width(self, line_width: usize) -> Self
pub fn with_line_width(self, line_width: usize) -> Self
Set the target line width (the column the printer tries to keep lines within), returning the updated options so calls can be chained.
Sourcepub fn with_indent_width(self, indent_width: usize) -> Self
pub fn with_indent_width(self, indent_width: usize) -> Self
Set the number of spaces per indentation level, returning the updated options so calls can be chained.
Sourcepub fn with_uppercase_keywords(self, uppercase_keywords: bool) -> Self
pub fn with_uppercase_keywords(self, uppercase_keywords: bool) -> Self
Choose whether SQL keywords are upper-cased, returning the updated options so calls can be chained.
Sourcepub fn with_keyword_case(self, keyword_case: KeywordCase) -> Self
pub fn with_keyword_case(self, keyword_case: KeywordCase) -> Self
Choose keyword casing, returning the updated options so calls can be chained.
Sourcepub fn with_line_ending(self, line_ending: LineEnding) -> Self
pub fn with_line_ending(self, line_ending: LineEnding) -> Self
Choose output line endings, returning the updated options so calls can be chained.
Sourcepub fn with_dialect(self, dialect: Dialect) -> Self
pub fn with_dialect(self, dialect: Dialect) -> Self
Set the SQL dialect to parse and format, returning the updated options so calls can be chained.
Trait Implementations§
Source§impl Clone for FormatOptions
impl Clone for FormatOptions
Source§fn clone(&self) -> FormatOptions
fn clone(&self) -> FormatOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FormatOptions
Source§impl Debug for FormatOptions
impl Debug for FormatOptions
Auto Trait Implementations§
impl Freeze for FormatOptions
impl RefUnwindSafe for FormatOptions
impl Send for FormatOptions
impl Sync for FormatOptions
impl Unpin for FormatOptions
impl UnsafeUnpin for FormatOptions
impl UnwindSafe for FormatOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more