pub struct DiagnosticRedactionBatch { /* private fields */ }Expand description
Accumulates independently resolvable redaction items under one budget.
Each operation returns an opaque handle. Handles are usable only with the
DiagnosticRedactionOutput produced by consuming this batch with
Self::finish_with_marker.
§Examples
use qubit_redact::Redactor;
let mut batch = Redactor::strict().diagnostic_batch();
let handle = batch.redact_field("password", "raw-secret");
let output = batch.finish_with_marker("<redaction incomplete>");
assert!(!output.text(handle).as_str().contains("raw-secret"));Implementations§
Source§impl DiagnosticRedactionBatch
impl DiagnosticRedactionBatch
Sourcepub fn is_output_exhausted(&self) -> bool
pub fn is_output_exhausted(&self) -> bool
Returns whether the shared output budget has closed this batch.
§Returns
True after the shared output boundary closes; later item operations cannot reopen it.
Sourcepub fn redact_field<T>(
&mut self,
field: &str,
value: &T,
) -> DiagnosticRedactionHandle
pub fn redact_field<T>( &mut self, field: &str, value: &T, ) -> DiagnosticRedactionHandle
Redacts one named scalar field and returns its opaque batch handle.
field selects the policy rule applied to value. The result remains
unpublished until Self::finish_with_marker consumes this batch.
§Type Parameters
T: Lazily evaluated scalar formatter.
§Parameters
field: Raw key admitted before classification and value access.value: Scalar formatter evaluated only when admission and masking require it.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_value<T>(&mut self, value: &T) -> DiagnosticRedactionHandle
pub fn redact_value<T>(&mut self, value: &T) -> DiagnosticRedactionHandle
Redacts one domain value and returns its opaque batch handle.
value is rendered only through its Redact implementation; the
result remains unpublished until
Self::finish_with_marker consumes this batch.
§Type Parameters
T: Domain type exposing structured redaction.
§Parameters
value: Borrowed domain value visited through structured redaction.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_argv<'items, I>(&mut self, items: I) -> DiagnosticRedactionHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
pub fn redact_argv<'items, I>(&mut self, items: I) -> DiagnosticRedactionHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
Redacts an explicitly classified argv sequence as one item.
The finite items iterator is admitted under this batch’s shared
resource budget before its values are inspected.
§Type Parameters
'items: Lifetime of borrowed argument contents.I: One-pass iterator of argument items.
§Parameters
items: Argument items visited once in source order.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_heuristic_argv<'items, I>(
&mut self,
items: I,
) -> DiagnosticRedactionHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
pub fn redact_heuristic_argv<'items, I>(
&mut self,
items: I,
) -> DiagnosticRedactionHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
Redacts an argv sequence with heuristic option classification as one item.
The finite items iterator is admitted under this batch’s shared
resource budget before its values are inspected.
§Type Parameters
'items: Lifetime of borrowed argument contents.I: One-pass iterator of argument items.
§Parameters
items: Argument items visited once in source order.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_env(
&mut self,
name: &str,
value: &str,
) -> DiagnosticRedactionHandle
pub fn redact_env( &mut self, name: &str, value: &str, ) -> DiagnosticRedactionHandle
Redacts one environment assignment as one item.
name selects the environment rule applied to value.
§Parameters
name: Environment name selecting the classification rule.value: Environment value admitted and transformed within the shared budget.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_env_pairs<'items, I>(
&mut self,
pairs: I,
) -> DiagnosticRedactionHandle
pub fn redact_env_pairs<'items, I>( &mut self, pairs: I, ) -> DiagnosticRedactionHandle
Redacts environment assignments as one item.
The finite pairs iterator is admitted before the renderer observes
later entries.
§Type Parameters
'items: Lifetime of borrowed names and values.I: One-pass iterator of environment assignments.
§Parameters
pairs: Native environment names and values visited once in source order.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_process<'arguments, 'variables, A, E>(
&mut self,
program: &'arguments OsStr,
arguments: A,
variables: E,
) -> DiagnosticRedactionHandlewhere
A: IntoIterator<Item = ArgvItem<'arguments>>,
E: IntoIterator<Item = (&'variables OsStr, &'variables OsStr)>,
pub fn redact_process<'arguments, 'variables, A, E>(
&mut self,
program: &'arguments OsStr,
arguments: A,
variables: E,
) -> DiagnosticRedactionHandlewhere
A: IntoIterator<Item = ArgvItem<'arguments>>,
E: IntoIterator<Item = (&'variables OsStr, &'variables OsStr)>,
Redacts one process command as one item.
program precedes arguments; variables are rendered after argv
when the shared budget still admits them.
§Type Parameters
'arguments: Borrow of the executable and arguments.'variables: Borrow of environment names and values.A: One-pass iterator of arguments.E: One-pass iterator of environment assignments.
§Parameters
program: Native executable name preceding the arguments.arguments: Arguments visited once in command order.variables: Environment assignments visited after argv when admission remains open.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_json(&mut self, text: &str) -> DiagnosticRedactionHandle
pub fn redact_json(&mut self, text: &str) -> DiagnosticRedactionHandle
Sourcepub fn redact_json_value(&mut self, value: &Value) -> DiagnosticRedactionHandle
pub fn redact_json_value(&mut self, value: &Value) -> DiagnosticRedactionHandle
Sourcepub fn redact_http_url(&mut self, value: &str) -> DiagnosticRedactionHandle
pub fn redact_http_url(&mut self, value: &str) -> DiagnosticRedactionHandle
Sourcepub fn redact_http_headers(
&mut self,
headers: &HeaderMap,
) -> DiagnosticRedactionHandle
pub fn redact_http_headers( &mut self, headers: &HeaderMap, ) -> DiagnosticRedactionHandle
Sourcepub fn redact_http_body(
&mut self,
capture: BodyCapture<'_>,
content_type: Option<&HeaderValue>,
) -> DiagnosticRedactionHandle
pub fn redact_http_body( &mut self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, ) -> DiagnosticRedactionHandle
Redacts one captured HTTP body as one item using optional parsed content-type metadata.
§Parameters
capture: Captured bytes with their completeness metadata.content_type: Optional media type; None preserves missing-type policy behavior.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_http_body_with_content_type_text(
&mut self,
capture: BodyCapture<'_>,
content_type: Option<&str>,
) -> DiagnosticRedactionHandle
pub fn redact_http_body_with_content_type_text( &mut self, capture: BodyCapture<'_>, content_type: Option<&str>, ) -> DiagnosticRedactionHandle
Redacts one captured HTTP body using optional textual content-type metadata.
§Parameters
capture: Captured bytes with their completeness metadata.content_type: Optional media type; None preserves missing-type policy behavior.
§Returns
An opaque handle to the recorded item, resolvable after this batch is finished.
Sourcepub fn redact_uri(&mut self, value: &str) -> DiagnosticRedactionHandle
pub fn redact_uri(&mut self, value: &str) -> DiagnosticRedactionHandle
Sourcepub fn finish_with_marker(self, marker: &str) -> DiagnosticRedactionOutput
pub fn finish_with_marker(self, marker: &str) -> DiagnosticRedactionOutput
Consumes the batch and prepares fail-closed diagnostic presentation.
Complete items retain their redacted text. Incomplete items and invalid
handles resolve to the escaped marker without returning an error.
§Parameters
marker: Caller-selected fallback escaped once outside the batch’s output budget.
§Returns
A diagnostic publication resolving complete items to their text and all others to the marker.
Sourcepub fn finish(self) -> DiagnosticRedactionOutput
pub fn finish(self) -> DiagnosticRedactionOutput
Consumes the batch and publishes fail-closed diagnostics using the standard incomplete-redaction marker.