Skip to main content

HttpRedactor

Struct HttpRedactor 

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

Applies one immutable HTTP policy to URLs, forms, headers, and bodies.

Implementations§

Source§

impl HttpRedactor

Source

pub fn new(policy: RedactionPolicy) -> Self

Creates a redactor from one immutable HTTP policy.

§Parameters
  • policy - Complete HTTP policy snapshot.
§Returns

A unified HTTP redactor with independent field contexts.

Source

pub fn strict() -> Self

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

The strict snapshot masks unknown structured fields and redacts non-root URL paths while retaining the configured resource limits.

Source

pub const fn policy(&self) -> &RedactionPolicy

Returns the immutable HTTP policy snapshot.

§Returns

The policy used by every operation on this redactor.

Source

pub fn redact_url(&self, url: &Url) -> LogSafeText<'static>

Redacts a parsed URL into log-safe text.

User information, passwords, fragments, sensitive query values, and non-root paths under a strict policy never reach the result. Complete HTTP URLs used as non-sensitive query values are redacted recursively under fixed nesting and percent-decoding limits; exceeding either limit fails closed.

§Parameters
  • url - Parsed URL to redact.
§Returns

An owned log-safe URL representation.

Source

pub fn redact_urls_in_text(&self, text: &str) -> LogSafeText<'static>

Redacts every HTTP URL-looking token in diagnostic text.

Surrounding prose and punctuation are preserved. Invalid URL-looking tokens fail closed, and log-control characters are escaped once after all URL replacements are complete.

§Parameters
  • text - Diagnostic text that may contain absolute HTTP URLs.
§Returns

Owned log-safe text with recognized URLs redacted.

Source

pub fn redact_url_str(&self, input: &str) -> LogSafeText<'static>

Parses and redacts a URL, failing closed on invalid input.

§Parameters
  • input - Absolute URL text.
§Returns

A safe redacted URL or a fixed invalid-URL marker.

Source

pub fn redact_form(&self, input: &str) -> LogSafeText<'static>

Redacts URL-encoded form text, failing closed on ambiguity.

§Parameters
  • input - URL-encoded form text.
§Returns

A safe redacted form or a fixed invalid-form marker.

Source

pub fn redact_headers(&self, headers: &HeaderMap) -> RedactedHeaders

Redacts and deterministically renders all HTTP header values.

Native sensitive values are always masked at Secret level before any name-based allow rule can apply. Non-UTF-8 values use a fixed marker.

§Parameters
  • headers - HTTP header map to redact.
§Returns

An opaque result whose Display and Debug expose only safe text.

Source

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

Redacts a checked body capture under hard input and output limits.

Parsers can observe only the prefix selected before dispatch. The final representation is escaped first and then bounded with a complete truncation marker.

§Parameters
  • capture - Checked complete or source-truncated body capture.
  • content_type - Optional Content-Type used for parser selection.
§Returns

A bounded result exposing only log-safe text and truthful metadata.

Source

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

Redacts a checked body capture selected by optional Content-Type text.

This accepts text from callers that do not retain a native HTTP header. Malformed Content-Type syntax is redacted fail-closed.

§Parameters
  • capture - Checked complete or source-truncated body capture.
  • content_type - Optional Content-Type text used for parser selection.
§Returns

A bounded result exposing only log-safe text and truthful metadata.

Source

pub fn redact_url_with_session( &self, url: &Url, session: &RedactionSession<'_>, ) -> LogSafeText<'static>

Redacts a URL while consuming the supplied diagnostic session.

Source

pub fn redact_urls_in_text_with_session( &self, text: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>

Redacts URL-looking tokens while consuming a shared diagnostic session.

Source

pub fn redact_url_str_with_session( &self, input: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>

Parses and redacts a URL while consuming a shared diagnostic session.

Source

pub fn redact_form_with_session( &self, input: &str, session: &RedactionSession<'_>, ) -> LogSafeText<'static>

Redacts a form while consuming a shared diagnostic session.

Source

pub fn redact_headers_with_session( &self, headers: &HeaderMap, session: &RedactionSession<'_>, ) -> RedactedHeaders

Redacts headers while consuming a shared diagnostic session.

Source

pub fn redact_body_with_session( &self, capture: BodyCapture<'_>, content_type: Option<&HeaderValue>, session: &RedactionSession<'_>, ) -> BodyRedaction

Redacts a body while consuming a shared diagnostic session.

Trait Implementations§

Source§

impl Clone for HttpRedactor

Source§

fn clone(&self) -> HttpRedactor

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 HttpRedactor

Source§

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

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

impl Default for HttpRedactor

Source§

fn default() -> Self

Creates a redactor from the current default HTTP policy.

§Returns

A fail-closed redactor with finite body limits.

Source§

impl Eq for HttpRedactor

Source§

impl PartialEq for HttpRedactor

Source§

fn eq(&self, other: &HttpRedactor) -> 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 HttpRedactor

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.