Skip to main content

FilterBuilder

Struct FilterBuilder 

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

链式构建组合过滤器。

所有条件以 AND 语义组合,调用 build 生成 Filter

§示例

use dm_database_parser_sqllog::FilterBuilder;

let filter = FilterBuilder::new()
    .exec_time_gt(100.0)
    .sql_contains("SELECT")
    .build();

Implementations§

Source§

impl FilterBuilder

Source

pub fn new() -> Self

创建一个空的 FilterBuilder(无任何谓词)。

Source

pub fn build(self) -> Filter

消费 builder,产出可复用的 Filter

Source

pub fn ts_gt(self, value: impl Into<String>) -> Self

时间戳晚于指定值(严格大于,FILTER-01)。

Source

pub fn ts_gte(self, value: impl Into<String>) -> Self

时间戳晚于或等于指定值(FILTER-01)。

Source

pub fn ts_lt(self, value: impl Into<String>) -> Self

时间戳早于指定值(严格小于,FILTER-01)。

Source

pub fn ts_lte(self, value: impl Into<String>) -> Self

时间戳早于或等于指定值(FILTER-01)。

Source

pub fn ts_between( self, start: impl Into<String>, end: impl Into<String>, ) -> Self

时间戳在闭区间 [start, end] 内(FILTER-01)。

§Panics

start > end 时 panic。

Source

pub fn tag_eq(self, value: impl Into<String>) -> Self

tag 字段等于指定值(FILTER-02)。

Source

pub fn ep_eq(self, value: u8) -> Self

EP 等于指定值(FILTER-03)。

Source

pub fn sess_id_eq(self, value: impl Into<String>) -> Self

sess_id 等于指定值(FILTER-04)。

Source

pub fn thrd_id_eq(self, value: impl Into<String>) -> Self

thrd_id 等于指定值(FILTER-04)。

Source

pub fn username_eq(self, value: impl Into<String>) -> Self

username 等于指定值(FILTER-04)。

Source

pub fn trxid_eq(self, value: impl Into<String>) -> Self

trxid 等于指定值(FILTER-04)。

Source

pub fn statement_eq(self, value: impl Into<String>) -> Self

statement 等于指定值(FILTER-04)。

Source

pub fn appname_eq(self, value: impl Into<String>) -> Self

appname 等于指定值(FILTER-04)。

Source

pub fn client_ip_eq(self, value: impl Into<String>) -> Self

client_ip 等于指定值(FILTER-04)。

Source

pub fn sql_contains(self, pattern: impl Into<String>) -> Self

SQL 语句包含指定子串(FILTER-05)。

Source

pub fn sql_eq(self, value: impl Into<String>) -> Self

SQL 语句等于指定值(FILTER-05)。

Source

pub fn sql_starts_with(self, prefix: impl Into<String>) -> Self

SQL 语句以指定前缀开头(FILTER-05)。

Source

pub fn sql_ends_with(self, suffix: impl Into<String>) -> Self

SQL 语句以指定后缀结尾(FILTER-05)。

Source

pub fn exec_time_gt(self, min_ms: f32) -> Self

执行时间大于 min_ms 毫秒(严格不等,FILTER-06)。

参数单位为毫秒;f32 精度约 7 位有效数字,不提供 exec_time_eq 方法以避免误用。

Source

pub fn exec_time_gte(self, min_ms: f32) -> Self

执行时间大于等于 min_ms 毫秒(含边界,FILTER-06)。

与 [LogIterator::filter_by_exec_time] 语义一致(>=)。 参数单位为毫秒;f32 精度约 7 位有效数字。

Source

pub fn exec_time_lt(self, max_ms: f32) -> Self

执行时间小于 max_ms 毫秒(FILTER-06)。

参数单位为毫秒;f32 精度约 7 位有效数字,不提供 exec_time_eq 方法以避免误用。

Source

pub fn exec_time_between(self, min_ms: f32, max_ms: f32) -> Self

执行时间在闭区间 [min_ms, max_ms] 毫秒内(FILTER-06)。

参数单位为毫秒;f32 精度约 7 位有效数字,不提供 exec_time_eq 方法以避免误用。

§Panics

min_ms > max_ms 时 panic。

Source

pub fn rowcount_eq(self, value: u32) -> Self

影响行数等于指定值(FILTER-07)。

Source

pub fn rowcount_gt(self, value: u32) -> Self

影响行数大于指定值(FILTER-07)。

Source

pub fn rowcount_lt(self, value: u32) -> Self

影响行数小于指定值(FILTER-07)。

Source

pub fn exec_id_eq(self, value: i64) -> Self

执行 ID 等于指定值(FILTER-08)。

Trait Implementations§

Source§

impl Default for FilterBuilder

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.