pub enum Filter<W> {
And {
and: Vec<Filter<W>>,
},
Or {
or: Vec<Filter<W>>,
},
Leaf(W),
}Expand description
类型化布尔过滤树(C2a 类型化层)。
在类型化叶子 W(一般是 T::WhereCond,JSON 形态 {"field":..,"cond":..})之上
叠加 And/Or 嵌套结构,端到端保持字段名/操作符的编译期类型安全,同时支持任意
深度的布尔组合。
§JSON 线格式(#[serde(untagged)])
一个节点是以下三者之一:
- AND 组:
{"and": [<子节点>, ...]} - OR 组:
{"or": [<子节点>, ...]} - 叶子:直接是
W的形态,如{"field":"age","cond":{"op":"gte","value":18}}
{
"or": [
{"field": "status", "cond": {"op": "eq", "value": "active"}},
{"and": [
{"field": "age", "cond": {"op": "gte", "value": 18}},
{"field": "vip", "cond": {"op": "eq", "value": true}}
]}
]
}§与受保护层桥接
Filter::into_where_condition 把整棵树降解为受保护层的
WhereCondition,叶子经 IntoSqlCondition →
SqlCondition → WhereCondition,由 TableQuery 统一做递归权限校验与渲染。
Variants§
Implementations§
Source§impl<W: IntoSqlCondition> Filter<W>
impl<W: IntoSqlCondition> Filter<W>
Sourcepub fn into_where_condition(self) -> WhereCondition
pub fn into_where_condition(self) -> WhereCondition
把类型化布尔树降解为受保护层的 WhereCondition。
叶子经 into_sql_condition() → into_where_condition() 转换;组节点递归降解。
不做深度限制(受保护层 TableQuery 在校验/渲染期统一施加
MAX_WHERE_DEPTH 上限并返回错误)。
Trait Implementations§
Source§impl<'de, W> Deserialize<'de> for Filter<W>where
W: Deserialize<'de>,
impl<'de, W> Deserialize<'de> for Filter<W>where
W: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<W: JsonSchema> JsonSchema for Filter<W>
impl<W: JsonSchema> JsonSchema for Filter<W>
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl<W> Freeze for Filter<W>where
W: Freeze,
impl<W> RefUnwindSafe for Filter<W>where
W: RefUnwindSafe,
impl<W> Send for Filter<W>where
W: Send,
impl<W> Sync for Filter<W>where
W: Sync,
impl<W> Unpin for Filter<W>where
W: Unpin,
impl<W> UnsafeUnpin for Filter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Filter<W>where
W: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more