Skip to main content

qubit_redact/policy/field/
field_match_kind.rs

1// =============================================================================
2//    Copyright (c) 2025 - 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! The canonical field-name candidate selected by policy classification.
9
10/// Identifies the candidate that matched a configured field rule.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_redact::{FieldMatchKind, RedactionPolicy};
16///
17/// let policy = RedactionPolicy::builder()
18///     .fields(|fields| {
19///         fields.matching(qubit_redact::FieldNameMatching::ExactOrTokenSuffix);
20///         fields.secret_sensitive("password");
21///     })
22///     .expect("the field rules should be valid")
23///     .build()
24///     .expect("the policy should be valid");
25/// let classification = policy.classify_field("db_password");
26/// assert_eq!(classification.match_kind(), Some(FieldMatchKind::TokenSuffix));
27/// ```
28#[non_exhaustive]
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
30pub enum FieldMatchKind {
31    /// The complete canonical input field name matched.
32    Exact,
33    /// A semantic token suffix of the input field name matched.
34    TokenSuffix,
35}