qubit_redact/facade/redactor/domain.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//! Domain-value and scalar-field redaction operations.
9
10use super::Redactor;
11use crate::Redact;
12use crate::RedactionInspection;
13use crate::RedactionInspectionError;
14use crate::RedactionTextOutput;
15use crate::runtime::runtime_session::RuntimeSession;
16
17impl Redactor {
18 /// Redacts one domain value into final text and an execution summary.
19 #[must_use]
20 pub fn redact<T>(&self, value: &T) -> RedactionTextOutput
21 where
22 T: Redact + ?Sized,
23 {
24 let mut session = self.text_runtime();
25 let _ = session.value(value);
26 session.finish()
27 }
28
29 /// Inspects one domain value without rendering any field content.
30 ///
31 /// # Errors
32 ///
33 /// Returns an inconclusive result when structural or input admission
34 /// prevents the complete domain value from being classified.
35 pub fn inspect<T>(&self, value: &T) -> Result<RedactionInspection, RedactionInspectionError>
36 where
37 T: Redact + ?Sized,
38 {
39 let mut session = self.inspection_runtime();
40 session.inspect(value);
41 session.finish()
42 }
43
44 /// Redacts one scalar field through a complete one-item transaction.
45 #[must_use]
46 pub fn redact_field<T>(&self, field: &str, value: &T) -> RedactionTextOutput
47 where
48 T: std::fmt::Display + ?Sized,
49 {
50 let mut session = self.text_runtime();
51 let _ = session.field(field, value);
52 session.finish()
53 }
54
55 /// Inspects one scalar field without rendering its value.
56 ///
57 /// # Errors
58 ///
59 /// Returns [`RedactionInspectionError`] when the shared input or
60 /// structural budget prevents a conclusive classification.
61 pub fn inspect_field(&self, field: &str, value: &str) -> Result<RedactionInspection, RedactionInspectionError> {
62 let mut session = self.inspection_runtime();
63 session.inspect_field(field, value);
64 session.finish()
65 }
66}