Skip to main content

qubit_redact/policy/field/
field_name_matching.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//! Field-name matching modes used by redaction policies.
9
10/// Controls which canonical field-name candidates may match policy rules.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_redact::{FieldNameMatching, RedactionPolicy};
16///
17/// let policy = RedactionPolicy::builder()
18///     .fields(|fields| {
19///         fields.matching(FieldNameMatching::ExactOrTokenSuffix);
20///     })
21///     .expect("the field rules should be valid")
22///     .build()
23///     .expect("the policy should be valid");
24/// assert_eq!(policy.matching(), FieldNameMatching::ExactOrTokenSuffix);
25/// ```
26#[non_exhaustive]
27#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
28pub enum FieldNameMatching {
29    /// Matches only the complete canonical field name.
30    Exact,
31    /// Matches the complete name and semantic token suffixes.
32    ExactOrTokenSuffix,
33}