Sqllog

Struct Sqllog 

Source
pub struct Sqllog {
    pub ts: String,
    pub meta: MetaParts,
    pub body: String,
    pub indicators: Option<IndicatorsParts>,
}
Expand description

SQL 日志记录

表示一条完整的 SQL 日志记录,包含时间戳、元数据、SQL 语句体和可选的性能指标。

§示例

use dm_database_parser_sqllog::parse_sqllogs_from_string;

let log = r#"2025-08-12 10:57:09.548 (EP[0] sess:123 thrd:456 user:alice trxid:789 stmt:999 appname:app) SELECT 1"#;
let results = parse_sqllogs_from_string(log);

if let Ok(sqllog) = &results[0] {
    assert_eq!(sqllog.ts, "2025-08-12 10:57:09.548");
    assert_eq!(sqllog.meta.username, "alice");
    assert_eq!(sqllog.body, "SELECT 1");
}

Fields§

§ts: String

时间戳,格式为 “YYYY-MM-DD HH:MM:SS.mmm”

§meta: MetaParts

元数据部分,包含会话信息、用户信息等

§body: String

SQL 语句体

§indicators: Option<IndicatorsParts>

可选的性能指标信息

Implementations§

Source§

impl Sqllog

Source

pub fn has_indicators(&self) -> bool

判断是否有性能指标信息

§返回

如果存在性能指标返回 true,否则返回 false

Source

pub fn execute_time(&self) -> Option<f32>

获取执行时间(毫秒)

§返回

如果存在性能指标返回执行时间,否则返回 None

Source

pub fn row_count(&self) -> Option<u32>

获取影响行数

§返回

如果存在性能指标返回影响行数,否则返回 None

Source

pub fn execute_id(&self) -> Option<i64>

获取执行 ID

§返回

如果存在性能指标返回执行 ID,否则返回 None

Trait Implementations§

Source§

impl Clone for Sqllog

Source§

fn clone(&self) -> Sqllog

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sqllog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Sqllog

Source§

fn default() -> Sqllog

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

impl PartialEq for Sqllog

Source§

fn eq(&self, other: &Sqllog) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Sqllog

Auto Trait Implementations§

§

impl Freeze for Sqllog

§

impl RefUnwindSafe for Sqllog

§

impl Send for Sqllog

§

impl Sync for Sqllog

§

impl Unpin for Sqllog

§

impl UnwindSafe for Sqllog

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.