pub struct DumpOptions {
pub include_fields: HashSet<String>,
pub exclude_fields: HashSet<String>,
pub exclude_none: bool,
pub indent: Option<usize>,
pub recursive: bool,
}Expand description
Options for controlling serialization output.
Mirrors Pydantic’s model_dump() parameters.
§Example
use rusdantic_core::dump::DumpOptions;
let opts = DumpOptions::new()
.exclude(&["password", "secret"])
.exclude_none(true);Fields§
§include_fields: HashSet<String>Only include these fields in the output (whitelist). If empty, all fields are included.
exclude_fields: HashSet<String>Exclude these fields from the output (blacklist).
exclude_none: boolIf true, skip fields with None values.
indent: Option<usize>Indentation for JSON output (None = compact).
recursive: boolIf true, apply include/exclude/exclude_none recursively to nested objects. Default: false (only filter top-level fields, matching Pydantic behavior).
Implementations§
Source§impl DumpOptions
impl DumpOptions
Sourcepub fn exclude_none(self, yes: bool) -> Self
pub fn exclude_none(self, yes: bool) -> Self
If true, skip fields with None / null values.
Sourcepub fn filter_value(&self, value: &mut Value)
pub fn filter_value(&self, value: &mut Value)
Apply options to a serialized JSON Value, filtering fields.
By default, only top-level fields are filtered (matching Pydantic behavior).
Set recursive(true) to also filter nested objects.
Trait Implementations§
Source§impl Clone for DumpOptions
impl Clone for DumpOptions
Source§fn clone(&self) -> DumpOptions
fn clone(&self) -> DumpOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DumpOptions
impl Debug for DumpOptions
Source§impl Default for DumpOptions
impl Default for DumpOptions
Source§fn default() -> DumpOptions
fn default() -> DumpOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DumpOptions
impl RefUnwindSafe for DumpOptions
impl Send for DumpOptions
impl Sync for DumpOptions
impl Unpin for DumpOptions
impl UnsafeUnpin for DumpOptions
impl UnwindSafe for DumpOptions
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
Mutably borrows from an owned value. Read more