Skip to main content

DiagnosticRedactionBatch

Struct DiagnosticRedactionBatch 

Source
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

Source

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.

Source

pub fn redact_field<T>( &mut self, field: &str, value: &T, ) -> DiagnosticRedactionHandle
where T: Display + ?Sized,

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.

Source

pub fn redact_value<T>(&mut self, value: &T) -> DiagnosticRedactionHandle
where T: Redact + ?Sized,

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.

Source

pub fn redact_argv<'items, I>(&mut self, items: I) -> DiagnosticRedactionHandle
where 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.

Source

pub fn redact_heuristic_argv<'items, I>( &mut self, items: I, ) -> DiagnosticRedactionHandle
where 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.

Source

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.

Source

pub fn redact_env_pairs<'items, I>( &mut self, pairs: I, ) -> DiagnosticRedactionHandle
where I: IntoIterator<Item = (&'items OsStr, &'items OsStr)>,

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.

Source

pub fn redact_process<'arguments, 'variables, A, E>( &mut self, program: &'arguments OsStr, arguments: A, variables: E, ) -> DiagnosticRedactionHandle
where 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.

Source

pub fn redact_json(&mut self, text: &str) -> DiagnosticRedactionHandle

Redacts one JSON document as one item.

Invalid JSON produces a safe result carrying InvalidJson provenance.

§Parameters
  • text: Raw JSON document admitted and parsed within the shared budget.
§Returns

An opaque handle to the recorded item, resolvable after this batch is finished.

Source

pub fn redact_json_value(&mut self, value: &Value) -> DiagnosticRedactionHandle

Redacts a borrowed parsed JSON value without taking ownership of it.

§Parameters
  • value: Parsed JSON value borrowed for admission and transformation.
§Returns

An opaque handle to the recorded item, resolvable after this batch is finished.

Source

pub fn redact_http_url(&mut self, value: &str) -> DiagnosticRedactionHandle

Redacts one HTTP URL as one item.

Invalid URLs produce a safe result carrying InvalidUri provenance.

§Parameters
  • value: Raw HTTP URL admitted before parsing.
§Returns

An opaque handle to the recorded item, resolvable after this batch is finished.

Source

pub fn redact_http_headers( &mut self, headers: &HeaderMap, ) -> DiagnosticRedactionHandle

Redacts one HTTP header map as one item.

§Parameters
  • headers: Header collection including repeated values.
§Returns

An opaque handle to the recorded item, resolvable after this batch is finished.

Source

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.

Source

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.

Source

pub fn redact_uri(&mut self, value: &str) -> DiagnosticRedactionHandle

Redacts one URI as one item.

§Parameters
  • value: Raw URI admitted before parsing.
§Returns

An opaque handle to the recorded item, resolvable after this batch is finished.

Source

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.

Source

pub fn finish(self) -> DiagnosticRedactionOutput

Consumes the batch and publishes fail-closed diagnostics using the standard incomplete-redaction marker.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.