#[non_exhaustive]pub struct ReplacementConfig {
pub key_replacements: SmallVec<[(String, String); 2]>,
pub value_replacements: SmallVec<[(String, String); 2]>,
pub key_exclusions: SmallVec<[String; 2]>,
pub value_exclusions: SmallVec<[String; 2]>,
}Expand description
Configuration for replacement operations
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.key_replacements: SmallVec<[(String, String); 2]>Key replacement patterns (find, replace) Uses SmallVec to avoid heap allocation for 0-2 replacements (common case)
value_replacements: SmallVec<[(String, String); 2]>Value replacement patterns (find, replace) Uses SmallVec to avoid heap allocation for 0-2 replacements (common case)
key_exclusions: SmallVec<[String; 2]>Patterns for excluding entire keys (and their values/subtrees) by name.
Literal substring match by default; wrap in r'...' for regex, matching
key_replacements’s convention. A key matches if any pattern is found in its
full dot-path (flatten/unflatten) or in its own name at that nesting level
(normal mode) – matching a container key drops its entire subtree without
walking it. See crate::builder::JSONTools::exclude_key for full docs.
value_exclusions: SmallVec<[String; 2]>Patterns for dropping a key-value pair by value content. Literal substring
match by default; wrap in r'...' for regex. Only ever applies to scalar leaf
values (strings/numbers/booleans/null) – containers have no single value to
check. Checked against the final value after any configured
value_replacement/auto_convert_types have run, matching remove_nulls’s
ordering guarantee. A no-op at the document root (no parent key to drop the
value from), same precedent as remove_nulls. See
crate::builder::JSONTools::exclude_value for full docs including the
unflatten quoted-form caveat.
Implementations§
Source§impl ReplacementConfig
impl ReplacementConfig
Sourcepub fn add_key_replacement(
self,
find: impl Into<String>,
replace: impl Into<String>,
) -> Self
pub fn add_key_replacement( self, find: impl Into<String>, replace: impl Into<String>, ) -> Self
Add a key replacement pattern
Sourcepub fn add_value_replacement(
self,
find: impl Into<String>,
replace: impl Into<String>,
) -> Self
pub fn add_value_replacement( self, find: impl Into<String>, replace: impl Into<String>, ) -> Self
Add a value replacement pattern
Sourcepub fn has_key_replacements(&self) -> bool
pub fn has_key_replacements(&self) -> bool
Check if any key replacements are configured
Sourcepub fn has_value_replacements(&self) -> bool
pub fn has_value_replacements(&self) -> bool
Check if any value replacements are configured
Sourcepub fn add_key_exclusion(self, pattern: impl Into<String>) -> Self
pub fn add_key_exclusion(self, pattern: impl Into<String>) -> Self
Add a key exclusion pattern
Sourcepub fn has_key_exclusions(&self) -> bool
pub fn has_key_exclusions(&self) -> bool
Check if any key exclusions are configured
Sourcepub fn add_value_exclusion(self, pattern: impl Into<String>) -> Self
pub fn add_value_exclusion(self, pattern: impl Into<String>) -> Self
Add a value exclusion pattern
Sourcepub fn has_value_exclusions(&self) -> bool
pub fn has_value_exclusions(&self) -> bool
Check if any value exclusions are configured
Trait Implementations§
Source§impl Clone for ReplacementConfig
impl Clone for ReplacementConfig
Source§fn clone(&self) -> ReplacementConfig
fn clone(&self) -> ReplacementConfig
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 ReplacementConfig
impl Debug for ReplacementConfig
Source§impl Default for ReplacementConfig
impl Default for ReplacementConfig
Source§fn default() -> ReplacementConfig
fn default() -> ReplacementConfig
Auto Trait Implementations§
impl Freeze for ReplacementConfig
impl RefUnwindSafe for ReplacementConfig
impl Send for ReplacementConfig
impl Sync for ReplacementConfig
impl Unpin for ReplacementConfig
impl UnsafeUnpin for ReplacementConfig
impl UnwindSafe for ReplacementConfig
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> 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