pub struct SerializerBuilder { /* private fields */ }Expand description
Builder for configuring serialization options
The SerializerBuilder provides a fluent API for customizing serialization behavior. It combines configuration from multiple internal types into a single, easy-to-use interface.
Implementations§
Source§impl SerializerBuilder
impl SerializerBuilder
Sourcepub fn indent_size(self, size: usize) -> Self
pub fn indent_size(self, size: usize) -> Self
Set the indentation size for formatted output
Controls the minimum padding for keys in human format. Set to 0 for no padding (default).
§Example
use serializer::SerializerBuilder;
let serializer = SerializerBuilder::new()
.indent_size(4)
.build();Sourcepub fn expand_keys(self, expand: bool) -> Self
pub fn expand_keys(self, expand: bool) -> Self
Set whether to expand abbreviated keys to full names
When true (default), keys like “nm” become “name” in human format. When false, abbreviated keys are preserved.
§Example
use serializer::SerializerBuilder;
let serializer = SerializerBuilder::new()
.expand_keys(false) // Keep "nm" instead of expanding to "name"
.build();Sourcepub fn use_list_format(self, use_list: bool) -> Self
pub fn use_list_format(self, use_list: bool) -> Self
Set whether to use list format for arrays
When true (default), arrays are formatted as:
items:
- first
- secondWhen false, arrays are formatted inline:
items = first | secondSourcepub fn space_around_equals(self, space: bool) -> Self
pub fn space_around_equals(self, space: bool) -> Self
Set whether to add spaces around equals signs
When true (default): key = value
When false: key=value
Sourcepub fn validate_output(self, validate: bool) -> Self
pub fn validate_output(self, validate: bool) -> Self
Set whether to validate output by parsing it back
When enabled, the serializer will parse the formatted output to ensure it’s valid. This catches formatting bugs but is slower.
Note: Currently disabled by default since V3 format round-trip is not fully implemented.
Sourcepub fn check_round_trip(self, check: bool) -> Self
pub fn check_round_trip(self, check: bool) -> Self
Set whether to check round-trip consistency
When enabled (requires validate_output), the serializer will verify that parsing the formatted output produces an equivalent document to the original.
Sourcepub fn output_dir<P: Into<PathBuf>>(self, dir: P) -> Self
pub fn output_dir<P: Into<PathBuf>>(self, dir: P) -> Self
Set the output directory for generated files
When set, the serializer can generate .human and .machine files in the specified directory. Default is “.dx/serializer”.
§Example
use serializer::SerializerBuilder;
let serializer = SerializerBuilder::new()
.output_dir("build/serializer")
.build();Sourcepub fn generate_llm(self, generate: bool) -> Self
pub fn generate_llm(self, generate: bool) -> Self
Set whether to generate LLM format files
When true (default), .llm files are generated in .dx/serializer.
Sourcepub fn generate_machine(self, generate: bool) -> Self
pub fn generate_machine(self, generate: bool) -> Self
Set whether to generate machine format files
When true (default), .machine files are generated for runtime use.
Sourcepub fn preserve_comments(self, preserve: bool) -> Self
pub fn preserve_comments(self, preserve: bool) -> Self
Set whether to preserve comments in output
Note: Comment preservation is not yet fully implemented. This option is reserved for future use.
Sourcepub fn compact_arrays(self, compact: bool) -> Self
pub fn compact_arrays(self, compact: bool) -> Self
Set whether to use compact array formatting
When true, arrays are formatted more compactly. This is equivalent to setting use_list_format(false).
Sourcepub fn for_tables(self) -> Self
pub fn for_tables(self) -> Self
Create a configuration optimized for tables and rules
This preset is useful for multi-row sections like lint rules. It sets appropriate padding and formatting for tabular data.
§Example
use serializer::SerializerBuilder;
let serializer = SerializerBuilder::new()
.for_tables()
.build();Sourcepub fn for_compact(self) -> Self
pub fn for_compact(self) -> Self
Create a configuration optimized for compact output
This preset minimizes whitespace and uses abbreviated keys. Useful for token-efficient LLM format.
Sourcepub fn for_humans(self) -> Self
pub fn for_humans(self) -> Self
Create a configuration optimized for human readability
This preset maximizes readability with expanded keys, proper spacing, and list formatting for arrays.
Sourcepub fn build(self) -> Serializer
pub fn build(self) -> Serializer
Build the configured Serializer
Creates a Serializer instance with all the specified options.
Trait Implementations§
Source§impl Clone for SerializerBuilder
impl Clone for SerializerBuilder
Source§fn clone(&self) -> SerializerBuilder
fn clone(&self) -> SerializerBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SerializerBuilder
impl Debug for SerializerBuilder
Auto Trait Implementations§
impl Freeze for SerializerBuilder
impl RefUnwindSafe for SerializerBuilder
impl Send for SerializerBuilder
impl Sync for SerializerBuilder
impl Unpin for SerializerBuilder
impl UnsafeUnpin for SerializerBuilder
impl UnwindSafe for SerializerBuilder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.