pub enum RecordTransform {
Flatten {
separator: String,
},
RenameKeys {
pattern: String,
replacement: String,
},
KeysCase {
mode: KeyCaseMode,
},
Select {
fields: Vec<String>,
},
Drop {
fields: Vec<String>,
},
Set {
values: Map<String, Value>,
},
RenameField {
fields: HashMap<String, String>,
},
Cast {
fields: HashMap<String, CastType>,
on_error: CastOnError,
},
Redact {
fields: Vec<String>,
mask: Value,
},
ValueCase {
fields: Vec<String>,
mode: ValueCaseMode,
},
SpellSymbols {
extra: HashMap<String, String>,
separator: String,
},
Custom(Arc<dyn Fn(Value) -> Value + Send + Sync>),
}Expand description
A transformation applied to every record fetched by a source (e.g. the REST
source’s RestStream).
Transforms are applied in the order they are added via the owning source’s
configuration (e.g. RestStreamConfig::add_transform).
The three built-in variants are each guarded by a Cargo feature flag
(all enabled by default — see module-level docs).
RecordTransform::Custom is always available and accepts any closure.
Variants§
Flatten
transform-flatten only.Flatten nested JSON objects into a single-level map.
Nested key paths are joined with separator. Arrays are left as-is.
Requires feature transform-flatten (default).
§Example
{"user": {"id": 1, "addr": {"city": "NYC"}}} → (separator = "__")
{"user__id": 1, "user__addr__city": "NYC"}RenameKeys
transform-rename-keys only.Apply a single regex substitution to every key in the record.
Keys in nested objects and objects inside arrays are also renamed
recursively. pattern is a Rust regex; replacement may reference
capture groups with $1, ${name}, etc. Chain multiple RenameKeys
transforms for multi-step pipelines.
Requires feature transform-rename-keys (default).
§Example
pattern = r"^_sdc_", replacement = "" → strip "_sdc_" prefixKeysCase
transform-keys-case only.Re-case every key in the record according to mode.
Tokenises each key on whitespace, _, -, dropped punctuation, and
lower→upper transitions, then re-joins in the requested convention.
Walks recursively into nested objects and arrays. Two distinct keys
that re-case to the same name error rather than silently overwriting.
Requires feature transform-keys-case (default).
| Input | Snake | Camel | Pascal | Kebab | ScreamingSnake |
|---|---|---|---|---|---|
"First Name" | "first_name" | "firstName" | "FirstName" | "first-name" | "FIRST_NAME" |
"last-name" | "last_name" | "lastName" | "LastName" | "last-name" | "LAST_NAME" |
"camelCase" | "camel_case" | "camelCase" | "CamelCase" | "camel-case" | "CAMEL_CASE" |
Fields
mode: KeyCaseModeSelect
transform-select only.Keep only the listed top-level fields on each record; remove the rest.
Missing fields are silently skipped (they don’t introduce nulls).
Non-object records pass through unchanged.
Requires feature transform-select.
Drop
transform-drop only.Remove the listed top-level fields from each record.
Missing fields are silently skipped. Non-object records pass through.
Requires feature transform-drop.
Set
transform-set only.Insert or overwrite top-level fields on each record with constant values.
Existing fields with the same name are overwritten. Non-object records pass through unchanged.
Requires feature transform-set.
RenameField
transform-rename-field only.Exact-name rename of one or more top-level fields.
Unlike RecordTransform::RenameKeys (regex, recursive), this only
touches exact top-level keys. Missing source fields are silently skipped.
If a target name already exists on the record, the rename errors rather
than silently overwriting.
Requires feature transform-rename-field.
Cast
transform-cast only.Coerce per-field types on each record.
Each named field is converted to the matching CastType. The
CastOnError policy controls failure behaviour. Missing fields are
silently skipped (no nulls introduced).
Requires feature transform-cast.
Redact
transform-redact only.Replace each listed field’s value with a constant mask.
Missing fields are silently skipped (no mask inserted). Default mask is
"***" when constructed from CLI config.
Requires feature transform-redact.
ValueCase
transform-value-case only.Lowercase / uppercase / trim string values on listed fields.
Non-string field values pass through unchanged. Missing fields are silently skipped.
Requires feature transform-value-case.
SpellSymbols
transform-spell-symbols only.Recursively spell out symbols inside every key with their word
equivalents (% → percent, # → number, $ → dollar, …).
Built-in defaults cover the common ASCII symbols (see
default_symbol_map); extra adds or overrides entries. Each
replacement is surrounded by separator (default " ") so a chained
RecordTransform::KeysCase picks up the word boundary.
Keys are walked recursively into nested objects and arrays, mirroring
the existing key-shape transforms. Two distinct keys that collapse to
the same name error rather than silently overwriting.
Requires feature transform-spell-symbols.
§Example
{"% sold": 1, "C# courses": 2}
→ (defaults, separator=" ")
{" percent sold": 1, "C number courses": 2}Fields
extra: HashMap<String, String>Additional mappings (merged on top of default_symbol_map;
entries with the same from override the default).
Custom(Arc<dyn Fn(Value) -> Value + Send + Sync>)
A user-supplied transformation function.
The function receives each record as a Value and returns the
(possibly modified) record. Construct one with RecordTransform::custom.
Always available — not guarded by any feature flag.
Implementations§
Source§impl RecordTransform
impl RecordTransform
Sourcepub fn custom<F>(f: F) -> RecordTransform
Available on crate feature source-rest only.
pub fn custom<F>(f: F) -> RecordTransform
source-rest only.Create a custom transform from any function or closure.
The closure receives each record as a Value and must return a
Value (the transformed record). It is called once per record and
may perform any manipulation — adding fields, removing fields, renaming,
type coercion, etc.
Custom transforms are always available regardless of feature flags.
§Example
use faucet_core::RecordTransform;
use serde_json::{Value, json};
// Inject a constant "source" field into every record.
let stamp = RecordTransform::custom(|mut record| {
if let Value::Object(ref mut map) = record {
map.insert("_source".to_string(), json!("my-api"));
}
record
});Trait Implementations§
Source§impl Clone for RecordTransform
impl Clone for RecordTransform
Source§fn clone(&self) -> RecordTransform
fn clone(&self) -> RecordTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RecordTransform
impl !RefUnwindSafe for RecordTransform
impl Send for RecordTransform
impl Sync for RecordTransform
impl Unpin for RecordTransform
impl UnsafeUnpin for RecordTransform
impl !UnwindSafe for RecordTransform
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.