qubit_metadata/missing_key_policy.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2025 - 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9//! [`MissingKeyPolicy`] — how filters treat missing keys for negative predicates.
10
11use serde::{Deserialize, Serialize};
12
13/// Policy that controls how filters treat missing keys for negative predicates.
14///
15/// The policy only affects [`crate::Condition::NotEqual`] and [`crate::Condition::NotIn`].
16/// Other predicates keep their existing semantics (`equal` requires presence,
17/// `exists` / `not_exists` check presence directly, etc.).
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
19pub enum MissingKeyPolicy {
20 /// Missing keys satisfy negative predicates (`not_equal`, `not_in_values`).
21 ///
22 /// This is the historical behavior and therefore the default.
23 #[default]
24 Match,
25 /// Missing keys do not satisfy negative predicates.
26 NoMatch,
27}
28
29impl MissingKeyPolicy {
30 #[inline]
31 pub(crate) const fn matches_negative_predicates(self) -> bool {
32 matches!(self, Self::Match)
33 }
34}