pub struct DumpOptions {
pub mode: DumpMode,
pub include: Option<HashSet<String>>,
pub exclude: Option<HashSet<String>>,
pub by_alias: bool,
pub exclude_unset: bool,
pub exclude_defaults: bool,
pub exclude_none: bool,
pub exclude_computed_fields: bool,
pub round_trip: bool,
pub indent: Option<usize>,
}Expand description
Options for model_dump() and model_dump_json().
Controls the serialization behavior.
Fields§
§mode: DumpModeOutput mode: Json or Python (Rust native).
Note: This option is currently NOT IMPLEMENTED. In Pydantic,
mode='json' returns JSON-compatible types (strings for dates) while
mode='python' returns native Python types (datetime objects). In Rust
with serde, type serialization is determined by Serialize implementations,
so both modes currently produce identical serde_json::Value output.
include: Option<HashSet<String>>Only include these fields (if Some)
exclude: Option<HashSet<String>>Exclude these fields
by_alias: boolUse field aliases in output.
When true, sql_model_dump() will rename fields to their
serialization_alias (or alias as fallback) in the output.
exclude_unset: boolExclude fields that were not explicitly set.
Note: This option is currently NOT IMPLEMENTED. It is defined for
API compatibility with Pydantic but has no effect. Full implementation
requires compile-time code generation to track which fields were
explicitly provided during construction (a fields_set: HashSet<String>).
This differs from exclude_defaults which compares current values to
known defaults.
Pydantic semantics: If a field has a default value and the user explicitly
sets it to that default, it should still be included (it was “set”).
With exclude_defaults, it would be excluded regardless of whether
it was explicitly provided.
exclude_defaults: boolExclude fields with default values
exclude_none: boolExclude fields with None/null values
exclude_computed_fields: boolExclude computed fields (for future computed_field support)
round_trip: boolEnable round-trip mode (preserves types for re-parsing).
Note: This option is currently NOT IMPLEMENTED. In Pydantic, round_trip mode serializes values in a way that can be deserialized back to the exact same model. In Rust with serde, round-trip fidelity is generally handled by the Serialize/Deserialize implementations.
indent: Option<usize>Indentation for JSON output (None = compact, Some(n) = n spaces)
Implementations§
Source§impl DumpOptions
impl DumpOptions
Sourcepub fn include(
self,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn include( self, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Set fields to include.
Sourcepub fn exclude(
self,
fields: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn exclude( self, fields: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Set fields to exclude.
Sourcepub fn exclude_unset(self) -> Self
pub fn exclude_unset(self) -> Self
Enable exclude_unset mode.
Sourcepub fn exclude_defaults(self) -> Self
pub fn exclude_defaults(self) -> Self
Enable exclude_defaults mode.
Sourcepub fn exclude_none(self) -> Self
pub fn exclude_none(self) -> Self
Enable exclude_none mode.
Sourcepub fn exclude_computed_fields(self) -> Self
pub fn exclude_computed_fields(self) -> Self
Enable exclude_computed_fields mode.
Sourcepub fn round_trip(self) -> Self
pub fn round_trip(self) -> Self
Enable round_trip mode.
Trait Implementations§
Source§impl Clone for DumpOptions
impl Clone for DumpOptions
Source§fn clone(&self) -> DumpOptions
fn clone(&self) -> DumpOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more