Skip to main content

qubit_redact/facade/redactor/
uri.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//! Generic URI redaction operations.
9
10use super::Redactor;
11use crate::RedactionInspection;
12use crate::RedactionInspectionError;
13use crate::RedactionTextOutput;
14
15impl Redactor {
16    /// Redacts a URI through one completed text transaction.
17    ///
18    /// # Parameters
19    ///
20    /// - `input`: Raw URI admitted before parsing and component classification.
21    ///
22    /// # Returns
23    ///
24    /// Final redacted text and its completion, reasons, and resource
25    /// accounting.
26    #[must_use]
27    #[inline]
28    pub fn redact_uri(&self, input: &str) -> RedactionTextOutput {
29        let mut session = self.text_runtime();
30        session.uri(|uri| {
31            let _ = uri.value(input);
32        });
33        session.finish()
34    }
35
36    /// Inspects one URI without rendering it.
37    ///
38    /// # Errors
39    ///
40    /// Returns [`RedactionInspectionError`] when URI parsing fails or a
41    /// shared resource limit prevents complete inspection.
42    ///
43    /// # Parameters
44    ///
45    /// - `input`: Raw URI to classify without rendering its components.
46    ///
47    /// # Returns
48    ///
49    /// A conclusive sensitivity inspection, or a value-free error retaining
50    /// usage and reasons.
51    #[inline]
52    pub fn inspect_uri(&self, input: &str) -> Result<RedactionInspection, RedactionInspectionError> {
53        let mut session = self.inspection_runtime();
54        crate::formats::uri::inspection::inspect_uri(&mut session, input);
55        session.finish()
56    }
57}