Skip to main content

DumpOptions

Struct DumpOptions 

Source
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: bool

If true, skip fields with None values.

§indent: Option<usize>

Indentation for JSON output (None = compact).

§recursive: bool

If true, apply include/exclude/exclude_none recursively to nested objects. Default: false (only filter top-level fields, matching Pydantic behavior).

Implementations§

Source§

impl DumpOptions

Source

pub fn new() -> Self

Create a new DumpOptions with default settings (include all, compact).

Source

pub fn include(self, fields: &[&str]) -> Self

Only include the specified fields in the output.

Source

pub fn exclude(self, fields: &[&str]) -> Self

Exclude the specified fields from the output.

Source

pub fn exclude_none(self, yes: bool) -> Self

If true, skip fields with None / null values.

Source

pub fn indent(self, spaces: usize) -> Self

Set JSON indentation (None = compact).

Source

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.

Source

pub fn recursive(self, yes: bool) -> Self

Set whether filtering applies recursively to nested objects.

Trait Implementations§

Source§

impl Clone for DumpOptions

Source§

fn clone(&self) -> DumpOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DumpOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DumpOptions

Source§

fn default() -> DumpOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.