pub struct FieldPromotion {
pub field: String,
pub state_key: String,
pub merge: MergePolicy,
pub accept: Option<PromotionPredicate>,
}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<PromotionPredicate>Optional acceptance predicate.
Implementations§
Source§impl FieldPromotion
impl FieldPromotion
Sourcepub fn keep_known(field: impl Into<String>) -> Self
pub fn keep_known(field: impl Into<String>) -> Self
Promote field into the same state key using MergePolicy::KeepKnown.
Sourcepub fn overwrite(field: impl Into<String>) -> Self
pub fn overwrite(field: impl Into<String>) -> Self
Promote field into the same state key using MergePolicy::Overwrite.
Sourcepub fn true_only(field: impl Into<String>) -> Self
pub fn true_only(field: impl Into<String>) -> Self
Promote a boolean field only when its extracted value is true.
Sourcepub fn non_empty(field: impl Into<String>) -> Self
pub fn non_empty(field: impl Into<String>) -> Self
Promote a string field only when its extracted value is non-empty.
Sourcepub fn accept_when(
self,
predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static,
) -> Self
pub fn accept_when( self, predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static, ) -> Self
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,
) -> Self
pub fn and_accept_when( self, predicate: impl Fn(&State, &Value) -> bool + Send + Sync + 'static, ) -> Self
Add an additional acceptance predicate, preserving any existing predicate.
Sourcepub fn after_presented(self, concept: impl Into<String>) -> Self
pub fn after_presented(self, concept: impl Into<String>) -> Self
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 more