pub struct RuleContext {
pub sql: String,
pub tokens: Vec<SqlToken>,
pub statement_type: SqlStatementType,
pub sql_upper: String,
}Expand description
规则匹配上下文,封装 SQL 文本及其预计算信息
由 RuleEngine::check 在执行规则前构建,避免每条规则重复词法分析。
Fields§
§sql: String原始 SQL 文本
tokens: Vec<SqlToken>词法分析后的令牌序列
statement_type: SqlStatementType语句类型
sql_upper: StringSQL 全大写形式(便于关键字匹配,避免重复计算)
Implementations§
Source§impl RuleContext
impl RuleContext
Sourcepub fn keyword_count(&self, keyword: &str) -> usize
pub fn keyword_count(&self, keyword: &str) -> usize
统计指定关键字的个数(基于令牌序列,精确匹配关键字令牌)
Sourcepub fn has_keyword(&self, keyword: &str) -> bool
pub fn has_keyword(&self, keyword: &str) -> bool
判断是否包含指定关键字
Sourcepub fn table_count(&self) -> usize
pub fn table_count(&self) -> usize
统计 FROM/JOIN/INTO/UPDATE 后的表标识符个数
Trait Implementations§
Source§impl Clone for RuleContext
impl Clone for RuleContext
Source§fn clone(&self) -> RuleContext
fn clone(&self) -> RuleContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RuleContext
impl RefUnwindSafe for RuleContext
impl Send for RuleContext
impl Sync for RuleContext
impl Unpin for RuleContext
impl UnsafeUnpin for RuleContext
impl UnwindSafe for RuleContext
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
Mutably borrows from an owned value. Read more