pub struct RedactionBatch { /* private fields */ }Expand description
Accumulates independently resolvable redaction items under one budget.
Each operation returns an opaque handle. Handles are usable only with the
RedactionBatchDiagnostics produced by consuming this batch with
Self::finish_for_diagnostics.
§Examples
use qubit_redact::Redactor;
let mut batch = Redactor::strict().batch();
let handle = batch.redact_field("password", "raw-secret");
let output = batch.finish_for_diagnostics("<redaction incomplete>");
assert!(!output.text(handle).as_str().contains("raw-secret"));Implementations§
Source§impl RedactionBatch
impl RedactionBatch
Sourcepub fn redact_field<T>(
&mut self,
field: &str,
value: &T,
) -> RedactionBatchHandle
pub fn redact_field<T>( &mut self, field: &str, value: &T, ) -> RedactionBatchHandle
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_for_diagnostics consumes this batch.
Sourcepub fn redact_value<T>(&mut self, value: &T) -> RedactionBatchHandle
pub fn redact_value<T>(&mut self, value: &T) -> RedactionBatchHandle
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_for_diagnostics consumes this batch.
Sourcepub fn redact_argv<'items, I>(&mut self, items: I) -> RedactionBatchHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
pub fn redact_argv<'items, I>(&mut self, items: I) -> RedactionBatchHandlewhere
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.
Sourcepub fn redact_heuristic_argv<'items, I>(
&mut self,
items: I,
) -> RedactionBatchHandlewhere
I: IntoIterator<Item = ArgvItem<'items>>,
pub fn redact_heuristic_argv<'items, I>(
&mut self,
items: I,
) -> RedactionBatchHandlewhere
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.
Sourcepub fn redact_env(&mut self, name: &str, value: &str) -> RedactionBatchHandle
pub fn redact_env(&mut self, name: &str, value: &str) -> RedactionBatchHandle
Redacts one environment assignment as one item.
name selects the environment rule applied to value.
Sourcepub fn redact_env_pairs<'items, I>(&mut self, pairs: I) -> RedactionBatchHandle
pub fn redact_env_pairs<'items, I>(&mut self, pairs: I) -> RedactionBatchHandle
Redacts environment assignments as one item.
The finite pairs iterator is admitted before the renderer observes
later entries.
Sourcepub fn redact_process<'arguments, 'variables, A, E>(
&mut self,
program: &'arguments OsStr,
arguments: A,
variables: E,
) -> RedactionBatchHandlewhere
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,
) -> RedactionBatchHandlewhere
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.
Sourcepub fn redact_json(&mut self, text: &str) -> RedactionBatchHandle
pub fn redact_json(&mut self, text: &str) -> RedactionBatchHandle
Redacts one JSON document as one item.
Invalid JSON produces a safe result carrying InvalidJson provenance.
Sourcepub fn redact_json_value(&mut self, value: &Value) -> RedactionBatchHandle
pub fn redact_json_value(&mut self, value: &Value) -> RedactionBatchHandle
Redacts a borrowed parsed JSON value without taking ownership of it.
Sourcepub fn redact_http_url(&mut self, value: &str) -> RedactionBatchHandle
pub fn redact_http_url(&mut self, value: &str) -> RedactionBatchHandle
Redacts one HTTP URL as one item.
Invalid URLs produce a safe result carrying InvalidUri provenance.
Sourcepub fn redact_http_headers(
&mut self,
headers: &HeaderMap,
) -> RedactionBatchHandle
pub fn redact_http_headers( &mut self, headers: &HeaderMap, ) -> RedactionBatchHandle
Redacts one HTTP header map as one item.
Sourcepub fn redact_http_body(
&mut self,
capture: BodyCapture<'_>,
content_type: Option<&HeaderValue>,
) -> RedactionBatchHandle
pub fn redact_http_body( &mut self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, ) -> RedactionBatchHandle
Redacts one captured HTTP body as one item using optional parsed content-type metadata.
Sourcepub fn redact_http_body_with_content_type_text(
&mut self,
capture: BodyCapture<'_>,
content_type: Option<&str>,
) -> RedactionBatchHandle
pub fn redact_http_body_with_content_type_text( &mut self, capture: BodyCapture<'_>, content_type: Option<&str>, ) -> RedactionBatchHandle
Redacts one captured HTTP body using optional textual content-type metadata.
Sourcepub fn redact_uri(&mut self, value: &str) -> RedactionBatchHandle
pub fn redact_uri(&mut self, value: &str) -> RedactionBatchHandle
Redacts one URI as one item.
Sourcepub fn finish_for_diagnostics(self, marker: &str) -> RedactionBatchDiagnostics
pub fn finish_for_diagnostics(self, marker: &str) -> RedactionBatchDiagnostics
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.