Struct FieldPromotion
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§
§impl FieldPromotion
impl FieldPromotion
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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| ...).
pub 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.
pub 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§
§impl Clone for FieldPromotion
impl Clone for FieldPromotion
§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