Skip to main content

qubit_redact/policy/
policy_location.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Location of a policy-building validation error.
9
10use std::fmt;
11
12/// Policy construction context where a validation error occurred.
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14#[non_exhaustive]
15pub enum PolicyLocation {
16    /// Regular field-rule construction context.
17    Rules,
18    /// Floor construction context.
19    Floor,
20    /// HTTP header field rules in an HTTP policy builder.
21    HttpHeader,
22    /// HTTP query and form field rules in an HTTP policy builder.
23    HttpQuery,
24    /// HTTP body field rules in an HTTP policy builder.
25    HttpBody,
26    /// Shared HTTP masking policy.
27    HttpMasking,
28}
29
30impl fmt::Display for PolicyLocation {
31    /// Writes the stable lowercase policy-location label.
32    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
33        match self {
34            Self::Rules => formatter.write_str("rules"),
35            Self::Floor => formatter.write_str("floor"),
36            Self::HttpHeader => formatter.write_str("http header"),
37            Self::HttpQuery => formatter.write_str("http query"),
38            Self::HttpBody => formatter.write_str("http body"),
39            Self::HttpMasking => formatter.write_str("http masking"),
40        }
41    }
42}