Skip to main content

qubit_redact/policy/
sensitive_field_rule.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//! Read-only views of configured sensitive-field rules.
9
10use super::Sensitivity;
11
12/// A borrowed canonical field name and its configured sensitivity.
13///
14/// # Type Parameters
15///
16/// * `'a` - Lifetime of the borrowed canonical field name.
17#[must_use]
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub struct SensitiveFieldRule<'a> {
20    /// Canonical field name.
21    field: &'a str,
22    /// Configured sensitivity level.
23    sensitivity: Sensitivity,
24}
25
26impl<'a> SensitiveFieldRule<'a> {
27    /// Creates a borrowed sensitive-field rule view.
28    ///
29    /// # Parameters
30    ///
31    /// * `field` - Canonical field name.
32    /// * `sensitivity` - Configured sensitivity level.
33    ///
34    /// # Returns
35    ///
36    /// A read-only view over the supplied rule.
37    #[inline]
38    pub(super) const fn new(field: &'a str, sensitivity: Sensitivity) -> Self {
39        Self { field, sensitivity }
40    }
41
42    /// Returns the canonical field name.
43    ///
44    /// # Returns
45    ///
46    /// The canonical field name borrowed from the policy.
47    #[must_use]
48    #[inline]
49    pub const fn field(&self) -> &'a str {
50        self.field
51    }
52
53    /// Returns the configured sensitivity level.
54    ///
55    /// # Returns
56    ///
57    /// The sensitivity assigned to the field.
58    #[inline]
59    pub const fn sensitivity(&self) -> Sensitivity {
60        self.sensitivity
61    }
62}