qubit_redact/formats/http/
http_redaction_policy.rs1use std::sync::Arc;
13
14use super::TextBodyPolicy;
15use super::UrlPathPolicy;
16use super::http_redaction_policy_parts::HttpPolicyParts;
17use crate::RedactionRules;
18
19#[derive(Debug, Clone, PartialEq, Eq)]
21pub struct HttpPolicy {
22 inner: Arc<HttpPolicyInner>,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq)]
28struct HttpPolicyInner {
29 header_rules: RedactionRules,
31 query_rules: RedactionRules,
33 body_rules: RedactionRules,
35 url_path_policy: UrlPathPolicy,
37 text_body_policy: TextBodyPolicy,
39}
40
41impl HttpPolicy {
42 #[must_use]
44 pub(super) fn from_parts(parts: HttpPolicyParts) -> Self {
45 Self {
46 inner: std::sync::Arc::new(HttpPolicyInner {
47 header_rules: parts.header_rules,
48 query_rules: parts.query_rules,
49 body_rules: parts.body_rules,
50 url_path_policy: parts.url_path_policy,
51 text_body_policy: parts.text_body_policy,
52 }),
53 }
54 }
55
56 #[must_use]
58 #[inline(always)]
59 pub fn header_rules(&self) -> &RedactionRules {
60 &self.inner.header_rules
61 }
62
63 #[must_use]
65 #[inline(always)]
66 pub fn query_rules(&self) -> &RedactionRules {
67 &self.inner.query_rules
68 }
69
70 #[must_use]
72 #[inline(always)]
73 pub fn body_rules(&self) -> &RedactionRules {
74 &self.inner.body_rules
75 }
76
77 #[must_use]
79 #[inline(always)]
80 pub fn url_path_policy(&self) -> UrlPathPolicy {
81 self.inner.url_path_policy
82 }
83
84 #[must_use]
86 #[inline(always)]
87 pub fn text_body_policy(&self) -> TextBodyPolicy {
88 self.inner.text_body_policy
89 }
90}