Skip to main content

Filter

Enum Filter 

Source
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§

§

And

AND 组:{"and": [...]},子节点全部成立。

Fields

§and: Vec<Filter<W>>

AND 子节点列表

§

Or

OR 组:{"or": [...]},子节点任一成立。

Fields

§or: Vec<Filter<W>>

OR 子节点列表

§

Leaf(W)

叶子节点:直接是类型化 where 条件 W。

Implementations§

Source§

impl<W: IntoSqlCondition> Filter<W>

Source

pub fn into_where_condition(self) -> WhereCondition

把类型化布尔树降解为受保护层的 WhereCondition。

叶子经 into_sql_condition() → into_where_condition() 转换;组节点递归降解。 不做深度限制(受保护层 TableQuery 在校验/渲染期统一施加 MAX_WHERE_DEPTH 上限并返回错误)。

Trait Implementations§

Source§

impl<W: Clone> Clone for Filter<W>

Source§

fn clone(&self) -> Filter<W>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<W: Debug> Debug for Filter<W>

Source§

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

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

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<W: JsonSchema> JsonSchema for Filter<W>

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

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

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more

Auto 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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more