pub struct MatchingRuleCategory {
pub name: Category,
pub rules: HashMap<DocPath, RuleList>,
}Expand description
Data structure for representing a category of matching rules
Fields§
§name: CategoryName of the category
rules: HashMap<DocPath, RuleList>Matching rules for this category
Implementations§
Source§impl MatchingRuleCategory
impl MatchingRuleCategory
Sourcepub fn empty<S>(name: S) -> MatchingRuleCategory
pub fn empty<S>(name: S) -> MatchingRuleCategory
Creates an empty category
Sourcepub fn equality<S>(name: S) -> MatchingRuleCategory
pub fn equality<S>(name: S) -> MatchingRuleCategory
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
pub fn filter<F>(&self, predicate: F) -> MatchingRuleCategory
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 add_v3_rules_from_json(&mut self, rules: &Value) -> Result<()>
pub fn add_v3_rules_from_json(&mut self, rules: &Value) -> Result<()>
Adds the rules to the category from the provided JSON in V3+ format
Sourcepub fn generators(&self) -> HashMap<DocPath, Generator>
pub fn generators(&self) -> HashMap<DocPath, Generator>
Returns any generators associated with these matching rules
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§
Source§impl Clone for MatchingRuleCategory
impl Clone for MatchingRuleCategory
Source§fn clone(&self) -> MatchingRuleCategory
fn clone(&self) -> MatchingRuleCategory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MatchingRuleCategory
impl Debug for MatchingRuleCategory
Source§impl Default for MatchingRuleCategory
impl Default for MatchingRuleCategory
Source§fn default() -> MatchingRuleCategory
fn default() -> MatchingRuleCategory
impl Eq for MatchingRuleCategory
Source§impl Hash for MatchingRuleCategory
impl Hash for MatchingRuleCategory
Source§impl Ord for MatchingRuleCategory
impl Ord for MatchingRuleCategory
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for MatchingRuleCategory
impl PartialEq for MatchingRuleCategory
Source§impl PartialOrd for MatchingRuleCategory
impl PartialOrd for MatchingRuleCategory
Auto Trait Implementations§
impl Freeze for MatchingRuleCategory
impl RefUnwindSafe for MatchingRuleCategory
impl Send for MatchingRuleCategory
impl Sync for MatchingRuleCategory
impl Unpin for MatchingRuleCategory
impl UnsafeUnpin for MatchingRuleCategory
impl UnwindSafe for MatchingRuleCategory
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);