Skip to main content

Redactor

Struct Redactor 

Source
pub struct Redactor { /* private fields */ }
Expand description

Applies one immutable policy snapshot to supported diagnostic values.

Composers and batches created from a redactor retain this snapshot even if the process-wide application default changes later. Self::replace_application_default is intentionally capable of installing a disabled policy for process-wide debugging; only future snapshots observe that replacement, and downstream code owns the confidentiality consequences.

§Design warning

The process-wide default and its ability to install RedactionPolicy::disabled are intentional public design, not a missing safety check. Code review must not report either capability as a defect or remove it as a hardening change without an explicit compatibility decision.

§Examples

use qubit_redact::Redactor;

let output = Redactor::strict().redact_field("password", "raw-secret");
assert!(!output.text().as_str().contains("raw-secret"));

Implementations§

Source§

impl Redactor

Source

pub fn redact<T>(&self, value: &T) -> RedactionTextOutput
where T: Redact + ?Sized,

Redacts one domain value into final text and an execution summary.

Source

pub fn inspect<T>( &self, value: &T, ) -> Result<RedactionInspection, RedactionInspectionError>
where T: Redact + ?Sized,

Inspects one domain value without rendering any field content.

§Errors

Returns an inconclusive result when structural or input admission prevents the complete domain value from being classified.

Source

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

Redacts one scalar field through a complete one-item transaction.

Source

pub fn inspect_field( &self, field: &str, value: &str, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one scalar field without rendering its value.

§Errors

Returns RedactionInspectionError when the shared input or structural budget prevents a conclusive classification.

Source§

impl Redactor

Source

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

Redacts an HTTP URL through one completed text transaction.

Source

pub fn inspect_http_url( &self, value: &str, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one HTTP URL without rendering it.

§Errors

Returns RedactionInspectionError when the URL is invalid or a shared resource limit prevents complete inspection.

Source

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

Redacts an HTTP header collection through one completed transaction.

Source

pub fn inspect_http_headers( &self, headers: &HeaderMap, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects HTTP headers without rendering their values.

§Errors

Returns RedactionInspectionError when a header cannot be decoded safely or a shared resource limit prevents complete inspection.

Source

pub fn redact_http_body( &self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, ) -> RedactionTextOutput

Redacts one captured HTTP body through one completed session transaction.

Source

pub fn inspect_http_body( &self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one captured HTTP body without rendering it.

§Errors

Returns RedactionInspectionError when capture metadata, content type, body syntax, or a shared resource limit makes inspection inconclusive.

Source

pub fn redact_http_body_with_content_type_text( &self, capture: BodyCapture<'_>, content_type: Option<&str>, ) -> RedactionTextOutput

Redacts one captured HTTP body using textual Content-Type metadata.

Source

pub fn inspect_http_body_with_content_type_text( &self, capture: BodyCapture<'_>, content_type: Option<&str>, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one captured HTTP body using textual Content-Type metadata.

§Errors

Returns RedactionInspectionError when capture metadata, content type, body syntax, or a shared resource limit makes inspection inconclusive.

Source§

impl Redactor

Source

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

Redacts JSON text through one completed text transaction.

Source

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

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

Source

pub fn inspect_json( &self, text: &str, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one JSON document without rendering it.

§Errors

Returns RedactionInspectionError when JSON parsing fails or a shared resource limit prevents complete inspection.

Source

pub fn inspect_json_value( &self, value: &Value, ) -> Result<RedactionInspection, RedactionInspectionError>

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

§Errors

Returns RedactionInspectionError when a shared structural, value, or input limit prevents complete inspection.

Source§

impl Redactor

Source

pub fn redact_argv<'items, I>(&self, items: I) -> RedactionTextOutput
where I: IntoIterator<Item = ArgvItem<'items>>,

Redacts an argument vector through one completed text transaction.

Source

pub fn inspect_argv<'items, I>( &self, items: I, ) -> Result<RedactionInspection, RedactionInspectionError>
where I: IntoIterator<Item = ArgvItem<'items>>,

Inspects explicitly classified argv items without rendering them.

§Errors

Returns RedactionInspectionError when non-UTF-8 data or a shared resource limit prevents complete inspection.

Source

pub fn redact_heuristic_argv<'items, I>(&self, items: I) -> RedactionTextOutput
where I: IntoIterator<Item = ArgvItem<'items>>,

Redacts argv items using heuristic option classification.

Source

pub fn inspect_heuristic_argv<'items, I>( &self, items: I, ) -> Result<RedactionInspection, RedactionInspectionError>
where I: IntoIterator<Item = ArgvItem<'items>>,

Inspects argv items using heuristic option classification.

§Errors

Returns RedactionInspectionError when non-UTF-8 data, incomplete option syntax, or a shared resource limit prevents complete inspection.

Source

pub fn redact_env(&self, name: &str, value: &str) -> RedactionTextOutput

Redacts one environment assignment through one completed transaction.

Source

pub fn inspect_env( &self, name: &str, value: &str, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one environment assignment without rendering it.

§Errors

Returns RedactionInspectionError when the shared input or structural budget prevents complete inspection.

Source

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

Redacts environment assignments through one completed transaction.

Source

pub fn inspect_env_pairs<'items, I>( &self, pairs: I, ) -> Result<RedactionInspection, RedactionInspectionError>
where I: IntoIterator<Item = (&'items OsStr, &'items OsStr)>,

Inspects environment assignments without rendering them.

§Errors

Returns RedactionInspectionError when non-UTF-8 data or a shared resource limit prevents complete inspection.

Source

pub fn redact_process<'arguments, 'variables, A, E>( &self, program: &'arguments OsStr, arguments: A, variables: E, ) -> RedactionTextOutput
where A: IntoIterator<Item = ArgvItem<'arguments>>, E: IntoIterator<Item = (&'variables OsStr, &'variables OsStr)>,

Redacts one process command through one completed text transaction.

Source

pub fn inspect_process<'arguments, 'variables, A, E>( &self, program: &'arguments OsStr, arguments: A, variables: E, ) -> Result<RedactionInspection, RedactionInspectionError>
where A: IntoIterator<Item = ArgvItem<'arguments>>, E: IntoIterator<Item = (&'variables OsStr, &'variables OsStr)>,

Inspects one process command without rendering its components.

§Errors

Returns RedactionInspectionError when argv or environment data is invalid, incomplete, or rejected by a shared resource limit.

Source§

impl Redactor

Source

pub fn redact_uri(&self, input: &str) -> RedactionTextOutput

Redacts a URI through one completed text transaction.

Source

pub fn inspect_uri( &self, input: &str, ) -> Result<RedactionInspection, RedactionInspectionError>

Inspects one URI without rendering it.

§Errors

Returns RedactionInspectionError when URI parsing fails or a shared resource limit prevents complete inspection.

Source§

impl Redactor

Source

pub fn new(policy: RedactionPolicy) -> Self

Creates a redactor using policy.

§Parameters
  • policy - Immutable field classification and masking configuration.
§Returns

A redactor that owns the supplied policy snapshot.

Source

pub fn standard() -> Self

Creates a redactor from the immutable built-in standard policy.

Source

pub fn strict() -> Self

Creates a redactor with the strict policy for untrusted scalar data.

Unknown fields are masked at crate::Sensitivity::Secret.

Source

pub fn application_default() -> Self

Returns a snapshot of the current application default redactor.

The returned value is detached from the global slot. Later calls to Self::replace_application_default do not alter this redactor or composers and batches created from it.

§Design warning

This API intentionally exposes the application default as a snapshot. Do not treat its process-wide source as a defect or replace it with an implicit per-call policy during review; downstream code relies on these snapshot semantics.

Source

pub fn replace_application_default(redactor: Self) -> Self

Atomically replaces the application default redactor.

The replacement is linearizable: concurrent readers observe either the complete previous snapshot or the complete new snapshot. Existing redactors, composers, and batches keep their own snapshots. The previous default is returned so callers can restore it after a scoped change. Installing RedactionPolicy::disabled is an intentional global debugging escape hatch. The framework does not authorize or reject that choice; the caller owns its environment and confidentiality boundary.

§Design warning

Accepting a redactor whose policy is RedactionPolicy::disabled is deliberate. Do not report this capability as a defect or remove it as a hardening change during review. It is required for explicitly authorized diagnostic debugging, and changes require a compatibility decision.

Source

pub fn policy(&self) -> &RedactionPolicy

Returns the immutable policy used by this redactor.

§Returns

A borrowed view of the redactor’s policy snapshot.

Source

pub fn text_composer(&self) -> RedactedTextComposer

Starts one ordered text-composition transaction.

The returned composer owns a fresh budget ledger initialized from this redactor’s immutable policy snapshot. Its consuming finish method publishes one crate::RedactionTextOutput.

§Returns

A composer for one independently bounded ordered text result.

Source

pub fn batch(&self) -> RedactionBatch

Starts one batch of independently resolvable redaction items.

The returned batch owns a fresh budget ledger initialized from this redactor’s immutable policy snapshot. Its consuming diagnostics finish method publishes fail-closed item views.

§Returns

A mutable batch that issues handles resolvable only from its finished output.

Trait Implementations§

Source§

impl Clone for Redactor

Source§

fn clone(&self) -> Redactor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Redactor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Redactor

Source§

fn default() -> Self

Creates a redactor from the deterministic standard policy.

§Returns

This implementation never reads mutable process-wide application state.

Source§

impl Eq for Redactor

Source§

impl PartialEq for Redactor

Source§

fn eq(&self, other: &Redactor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Redactor

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.