pub struct FieldPromotion {
pub field: String,
pub state_key: String,
pub merge: MergePolicy,
pub accept: Option<Arc<dyn Fn(&State, &Value) -> bool + Send + Sync>>,
}Expand description
Rule for promoting one raw extraction field into authoritative state.
Fields§
§field: StringField name inside the extractor’s JSON object.
state_key: StringState key to write when the field is accepted.
merge: MergePolicyMerge behavior for the target state key.
accept: Option<Arc<dyn Fn(&State, &Value) -> bool + Send + Sync>>Optional acceptance predicate.
Implementations§
Source§impl FieldPromotion
impl FieldPromotion
Sourcepub fn keep_known(field: impl Into<String>) -> FieldPromotion
pub fn keep_known(field: impl Into<String>) -> FieldPromotion
Promote field into the same state key using MergePolicy::KeepKnown.
Sourcepub fn overwrite(field: impl Into<String>) -> FieldPromotion
pub fn overwrite(field: impl Into<String>) -> FieldPromotion
Promote field into the same state key using MergePolicy::Overwrite.
Sourcepub fn true_only(field: impl Into<String>) -> FieldPromotion
pub fn true_only(field: impl Into<String>) -> FieldPromotion
Promote a boolean field only when its extracted value is true.
Sourcepub fn non_empty(field: impl Into<String>) -> FieldPromotion
pub fn non_empty(field: impl Into<String>) -> FieldPromotion
Promote a string field only when its extracted value is non-empty.
Sourcepub fn to(self, state_key: impl Into<String>) -> FieldPromotion
pub fn to(self, state_key: impl Into<String>) -> FieldPromotion
Promote into a custom target state key.
Sourcepub fn accept_when(
self,
predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static,
) -> FieldPromotion
pub fn accept_when( self, predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static, ) -> FieldPromotion
Only accept this promotion when predicate returns true.
This is the escape hatch for application-specific logic:
FieldPromotion::overwrite("intent").accept_when(|state, value| ...).
Sourcepub fn and_accept_when(
self,
predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static,
) -> FieldPromotion
pub fn and_accept_when( self, predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static, ) -> FieldPromotion
Add an additional acceptance predicate, preserving any existing predicate.
Sourcepub fn after_presented(self, concept: impl Into<String>) -> FieldPromotion
pub fn after_presented(self, concept: impl Into<String>) -> FieldPromotion
Only promote after the named concept has been presented by a phase.
Trait Implementations§
Source§impl Clone for FieldPromotion
impl Clone for FieldPromotion
Source§fn clone(&self) -> FieldPromotion
fn clone(&self) -> FieldPromotion
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FieldPromotion
impl !RefUnwindSafe for FieldPromotion
impl Send for FieldPromotion
impl Sync for FieldPromotion
impl Unpin for FieldPromotion
impl !UnwindSafe for FieldPromotion
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,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].