Skip to main content

RedactionBatch

Struct RedactionBatch 

Source
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

Source

pub fn redact_field<T>( &mut self, field: &str, value: &T, ) -> RedactionBatchHandle
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_for_diagnostics consumes this batch.

Source

pub fn redact_value<T>(&mut self, value: &T) -> RedactionBatchHandle
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_for_diagnostics consumes this batch.

Source

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

Source

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

Source

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.

Source

pub fn redact_env_pairs<'items, I>(&mut self, pairs: I) -> RedactionBatchHandle
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.

Source

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

Source

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.

Source

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

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

Source

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.

Source

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

Redacts one HTTP header map as one item.

Source

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.

Source

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.

Source

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

Redacts one URI as one item.

Source

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.

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.