Skip to main content

RuleManager

Struct RuleManager 

Source
pub struct RuleManager { /* private fields */ }
Expand description

An ordered set of rules, evaluated by decreasing priority.

Implementations§

Source§

impl RuleManager

Source

pub fn new() -> Self

An empty set of rules.

Source

pub fn activate_all(&mut self)

Activates every rule.

Source

pub fn add_rule(&mut self, rule: Box<dyn Rule>)

Adds a rule, keeping the set sorted by priority.

Source

pub fn relax_all(&mut self)

Relaxes every rule before a new pass.

Source

pub fn reset_all(&mut self)

Resets every rule.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear_rules(&mut self)

Removes every rule.

Source

pub fn is_active(&self) -> bool

Whether some relaxable rule is still active, i.e. whether the search may still be restricted.

Source

pub fn evaluate(&self, context: &RuleContext) -> RuleResult

Evaluates the rules in order and returns the first one that stops the search, or a result that lets it continue.

Source

pub fn get_rule_states(&self) -> Vec<(String, String)>

(description, state) of every rule.

Source

pub fn get_rule_mut<T: 'static>(&mut self) -> Option<&mut T>

The first rule of type T, if any.

Trait Implementations§

Source§

impl Default for RuleManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.