Skip to main content

RuleEngine

Struct RuleEngine 

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

规则引擎,管理规则集合并批量执行检查

规则按添加顺序执行,所有规则均会运行(不短路), 以便一次性收集全部违规。

Implementations§

Source§

impl RuleEngine

Source

pub fn new() -> Self

创建空规则引擎

Source

pub fn with_default_rules() -> Self

创建包含默认规则集的引擎

默认规则集包含:

Source

pub fn add_rule(&mut self, rule: Box<dyn SqlRule>) -> &mut Self

添加一条规则

Source

pub fn rule_count(&self) -> usize

返回规则数量

Source

pub fn check(&self, sql: &str) -> RuleReport

对单条 SQL 执行所有规则,返回汇总报告

Source

pub fn check_batch<'a>( &self, sqls: impl IntoIterator<Item = &'a str>, ) -> Vec<RuleReport>

对多条 SQL 批量执行检查,返回每条 SQL 的报告

Source

pub fn passes(&self, sql: &str) -> bool

检查 SQL 是否通过所有规则(无阻断级违规)

Trait Implementations§

Source§

impl Default for RuleEngine

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.