sz-orm-model 1.2.1

SZ-ORM Model trait, accessors, behaviors, and dirty attributes
Documentation
//! 执行器 trait(模型层与执行层的契约)
//!
//! 为避免 sz-orm-model 反向依赖 sz-orm-pool,定义此最小执行器 trait。
//! `sz-orm-pool` 中的 `Connection` trait 应实现此 trait,
//! 使 `Model` 的关系加载方法可以接受任意 `Executor` 实现。

use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;

use crate::error::DbError;
use crate::value::Value;

/// 查询结果行:`Vec<HashMap<列名, 值>>`
pub type QueryRows = Vec<HashMap<String, Value>>;

/// 最小执行器 trait
///
/// 抽象了"执行 SQL 并返回结果行"的能力。
/// `sz-orm-pool::Connection` 和测试中的 Mock 连接都应实现此 trait。
pub trait Executor {
    /// 执行查询 SQL,返回结果行
    fn execute_query<'a>(
        &'a mut self,
        sql: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>;
}