pub struct PayloadTransform {
pub operations: Vec<TransformOperation>,
pub start_empty: bool,
pub strict: bool,
}Expand description
Payload transformation configuration
Fields§
§operations: Vec<TransformOperation>Ordered list of transformation operations
start_empty: boolWhether to start with empty object (true) or clone input (false)
strict: boolFail on any error (true) or continue and skip failed operations (false)
Implementations§
Source§impl PayloadTransform
impl PayloadTransform
Sourcepub fn extract_field(self, source_path: &str, target_field: &str) -> Self
pub fn extract_field(self, source_path: &str, target_field: &str) -> Self
Add an extract operation
Sourcepub fn extract_field_or(
self,
source_path: &str,
target_field: &str,
default: Value,
) -> Self
pub fn extract_field_or( self, source_path: &str, target_field: &str, default: Value, ) -> Self
Add an optional extract operation with default
Sourcepub fn rename_field(self, from: &str, to: &str) -> Self
pub fn rename_field(self, from: &str, to: &str) -> Self
Add a rename operation
Sourcepub fn add_default(self, field: &str, value: Value) -> Self
pub fn add_default(self, field: &str, value: Value) -> Self
Add a constant value
Sourcepub fn remove_fields(self, fields: &[&str]) -> Self
pub fn remove_fields(self, fields: &[&str]) -> Self
Remove specific fields
Sourcepub fn filter_fields(self, fields: &[&str]) -> Self
pub fn filter_fields(self, fields: &[&str]) -> Self
Keep only specific fields
Sourcepub fn string_transform(
self,
source_path: &str,
target_field: &str,
transform: StringTransformType,
) -> Self
pub fn string_transform( self, source_path: &str, target_field: &str, transform: StringTransformType, ) -> Self
Add a string transform operation
Sourcepub fn map_value(
self,
source_path: &str,
target_field: &str,
mappings: HashMap<String, Value>,
default: Option<Value>,
) -> Self
pub fn map_value( self, source_path: &str, target_field: &str, mappings: HashMap<String, Value>, default: Option<Value>, ) -> Self
Add a value mapping operation
Sourcepub fn flatten(
self,
source_path: &str,
prefix: Option<&str>,
separator: &str,
) -> Self
pub fn flatten( self, source_path: &str, prefix: Option<&str>, separator: &str, ) -> Self
Add a flatten operation
Sourcepub fn add_operation(self, operation: TransformOperation) -> Self
pub fn add_operation(self, operation: TransformOperation) -> Self
Add a custom operation
Trait Implementations§
Source§impl Clone for PayloadTransform
impl Clone for PayloadTransform
Source§fn clone(&self) -> PayloadTransform
fn clone(&self) -> PayloadTransform
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 PayloadTransform
impl Debug for PayloadTransform
Source§impl Default for PayloadTransform
impl Default for PayloadTransform
Source§fn default() -> PayloadTransform
fn default() -> PayloadTransform
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PayloadTransform
impl<'de> Deserialize<'de> for PayloadTransform
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PayloadTransform
impl RefUnwindSafe for PayloadTransform
impl Send for PayloadTransform
impl Sync for PayloadTransform
impl Unpin for PayloadTransform
impl UnwindSafe for PayloadTransform
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