pub trait DataScopeExt: Sized {
// Required method
fn with_data_scope_conditions(self, conditions: &[WhereCondition]) -> Self;
// Provided method
fn data_scope_async<'life0, 'life1, 'life2, 'async_trait>(
self,
ctx: &'life0 DataScopeContext,
rule: &'life1 DataScopeRule,
evaluator: &'life2 dyn DataScopeEvaluator,
) -> Pin<Box<dyn Future<Output = Result<Self, DataScopeError>> + Send + 'async_trait>>
where Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
数据范围扩展 trait
为查询构建器实现此 trait 后,可链式调用 .data_scope_async(ctx, rule, evaluator)
自动注入数据范围 WHERE 条件。
Required Methods§
Sourcefn with_data_scope_conditions(self, conditions: &[WhereCondition]) -> Self
fn with_data_scope_conditions(self, conditions: &[WhereCondition]) -> Self
同步设置数据范围(需预先评估好的条件)
Provided Methods§
Sourcefn data_scope_async<'life0, 'life1, 'life2, 'async_trait>(
self,
ctx: &'life0 DataScopeContext,
rule: &'life1 DataScopeRule,
evaluator: &'life2 dyn DataScopeEvaluator,
) -> Pin<Box<dyn Future<Output = Result<Self, DataScopeError>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn data_scope_async<'life0, 'life1, 'life2, 'async_trait>(
self,
ctx: &'life0 DataScopeContext,
rule: &'life1 DataScopeRule,
evaluator: &'life2 dyn DataScopeEvaluator,
) -> Pin<Box<dyn Future<Output = Result<Self, DataScopeError>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
异步评估并注入数据范围
调用 evaluator.evaluate(ctx, rule) 获取条件列表,
逐个追加到查询构建器。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".