Struct pact_models::matchingrules::MatchingRuleCategory
source · [−]Expand description
Data structure for representing a category of matching rules
Fields
name: Category
Name of the category
rules: HashMap<DocPath, RuleList>
Matching rules for this category
Implementations
sourceimpl MatchingRuleCategory
impl MatchingRuleCategory
sourcepub fn empty<S>(name: S) -> MatchingRuleCategory where
S: Into<Category>,
pub fn empty<S>(name: S) -> MatchingRuleCategory where
S: Into<Category>,
Creates an empty category
sourcepub fn equality<S>(name: S) -> MatchingRuleCategory where
S: Into<Category>,
pub fn equality<S>(name: S) -> MatchingRuleCategory where
S: Into<Category>,
Creates a default category
sourcepub fn is_not_empty(&self) -> bool
pub fn is_not_empty(&self) -> bool
If the matching rules in the category are not empty
sourcepub fn rule_from_json(
&mut self,
key: DocPath,
matcher_json: &Value,
rule_logic: RuleLogic
) -> Result<()>
pub fn rule_from_json(
&mut self,
key: DocPath,
matcher_json: &Value,
rule_logic: RuleLogic
) -> Result<()>
Adds a rule from the Value representation
sourcepub fn add_rule(
&mut self,
key: DocPath,
matcher: MatchingRule,
rule_logic: RuleLogic
)
pub fn add_rule(
&mut self,
key: DocPath,
matcher: MatchingRule,
rule_logic: RuleLogic
)
Adds a rule to this category
sourcepub fn filter<F>(&self, predicate: F) -> MatchingRuleCategory where
F: Fn(&(&DocPath, &RuleList)) -> bool,
pub fn filter<F>(&self, predicate: F) -> MatchingRuleCategory where
F: Fn(&(&DocPath, &RuleList)) -> bool,
Filters the matchers in the category by the predicate, and returns a new category
sourcepub fn to_v3_json(&self) -> Value
pub fn to_v3_json(&self) -> Value
Returns a JSON Value representation in V3 format
sourcepub fn to_v2_json(&self) -> HashMap<String, Value>
pub fn to_v2_json(&self) -> HashMap<String, Value>
Returns a JSON Value representation in V2 format
sourcepub fn type_matcher_defined(&self) -> bool
pub fn type_matcher_defined(&self) -> bool
If there is a type matcher defined for the category
sourcepub fn values_matcher_defined(&self) -> bool
pub fn values_matcher_defined(&self) -> bool
If there is a values matcher defined in the rules
sourcepub fn matcher_is_defined(&self, path: &[&str]) -> bool
pub fn matcher_is_defined(&self, path: &[&str]) -> bool
If there is a matcher defined for the path
sourcepub fn resolve_matchers_for_path(&self, path: &[&str]) -> MatchingRuleCategory
pub fn resolve_matchers_for_path(&self, path: &[&str]) -> MatchingRuleCategory
filters this category with all rules that match the given path for categories that contain collections (eg. bodies, headers, query parameters). Returns self otherwise.
sourcepub fn select_best_matcher(&self, path: &[&str]) -> RuleList
pub fn select_best_matcher(&self, path: &[&str]) -> RuleList
Selects the best matcher for the given path by calculating a weighting for each one
sourcepub fn as_rule_list(&self) -> RuleList
pub fn as_rule_list(&self) -> RuleList
Returns this category as a matching rule list. Returns a None if there are no rules
sourcepub fn add_rules_from_json(&mut self, rules: &Value) -> Result<()>
pub fn add_rules_from_json(&mut self, rules: &Value) -> Result<()>
Adds the rules to the category from the provided JSON
sourcepub fn generators(&self) -> HashMap<DocPath, Generator>
pub fn generators(&self) -> HashMap<DocPath, Generator>
Returns any generators associated with these matching rules
sourcepub fn rename<S>(&self, name: S) -> Self where
S: Into<Category>,
pub fn rename<S>(&self, name: S) -> Self where
S: Into<Category>,
Clones this category with the new name
sourcepub fn add_rules(&mut self, category: MatchingRuleCategory)
pub fn add_rules(&mut self, category: MatchingRuleCategory)
Add all the rules from the provided rules
Trait Implementations
sourceimpl Clone for MatchingRuleCategory
impl Clone for MatchingRuleCategory
sourcefn clone(&self) -> MatchingRuleCategory
fn clone(&self) -> MatchingRuleCategory
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MatchingRuleCategory
impl Debug for MatchingRuleCategory
sourceimpl Default for MatchingRuleCategory
impl Default for MatchingRuleCategory
sourcefn default() -> MatchingRuleCategory
fn default() -> MatchingRuleCategory
Returns the “default value” for a type. Read more
sourceimpl Hash for MatchingRuleCategory
impl Hash for MatchingRuleCategory
sourceimpl Ord for MatchingRuleCategory
impl Ord for MatchingRuleCategory
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<MatchingRuleCategory> for MatchingRuleCategory
impl PartialOrd<MatchingRuleCategory> for MatchingRuleCategory
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for MatchingRuleCategory
impl StructuralEq for MatchingRuleCategory
Auto Trait Implementations
impl RefUnwindSafe for MatchingRuleCategory
impl Send for MatchingRuleCategory
impl Sync for MatchingRuleCategory
impl Unpin for MatchingRuleCategory
impl UnwindSafe for MatchingRuleCategory
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more