Skip to main content

RedactedView

Struct RedactedView 

Source
pub struct RedactedView<'value, T: ?Sized> { /* private fields */ }
Expand description

A lazy view of a source value under one fixed redaction policy.

Creation does not inspect or format the source. Each formatting or Serde call starts a fresh execution and budget, reading the source again. The policy is fixed, but interior-mutable source values are not snapshotted. This is neither a modified business object nor cached redacted output. Use Redactor::redact_text when a finalized text and summary are needed.

With the serde feature, views of derived values serialize structurally through their redacted field projections. The source’s ordinary Serialize implementation is not used as the root redaction entry point. Direct Serde observes logical payload limits; an external serializer owns its final encoded size. Redactor::to_json also bounds final JSON bytes.

§Type Parameters

  • 'value: Lifetime of the borrowed source.
  • T: Source type; formatting/serialization capabilities are required on use.

§Examples

use qubit_redact::{Redact, RedactionWriter, Redactor};
struct Event;
impl Redact for Event {
    fn write_redacted(&self, writer: &mut RedactionWriter<'_>) {
        writer.record("Event", |fields| {
            fields.unmarked("status", || "ready");
        });
    }
}
let event = Event;
let redactor = Redactor::standard();
let view = redactor.redact_view(&event);
assert_eq!(format!("{view}"), redactor.redact_text(&event).text().as_str());

Trait Implementations§

Source§

impl<T: Redact + ?Sized> Debug for RedactedView<'_, T>

Source§

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

Shows redacted text without exposing wrapper internals or source Debug.

§Parameters
  • formatter: Destination receiving the redacted text of a fresh execution.
§Returns

Success after publishing the rendered text.

§Errors

Propagates a destination formatting error; redaction failures remain safe output metadata.

Source§

impl<T: Redact + ?Sized> Display for RedactedView<'_, T>

Source§

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

Renders the source once through a fresh text transaction.

§Parameters
  • formatter: Destination receiving the redacted text of a fresh execution.
§Returns

Success after publishing the rendered text.

§Errors

Propagates a destination formatting error; redaction failures remain safe output metadata.

Source§

impl<'value, T: RedactSerializeSource + ?Sized> Serialize for RedactedView<'value, T>
where T::RedactedFields<'value>: Serialize,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes with this view’s policy, propagating serializer/budget errors.

§Type Parameters
  • S: Destination serializer and its result/error types.
§Parameters
  • serializer: Destination receiving the structured redacted projection.
§Returns

The destination result after one policy-scoped structured execution.

§Errors

Returns the serializer’s error for rejected admission or payload budgets, or propagates a downstream serialization error.

Auto Trait Implementations§

§

impl<'value, T> Freeze for RedactedView<'value, T>
where &'value T: Freeze, T: ?Sized,

§

impl<'value, T> RefUnwindSafe for RedactedView<'value, T>

§

impl<'value, T> Send for RedactedView<'value, T>
where &'value T: Send, T: ?Sized,

§

impl<'value, T> Sync for RedactedView<'value, T>
where &'value T: Sync, T: ?Sized,

§

impl<'value, T> Unpin for RedactedView<'value, T>
where &'value T: Unpin, T: ?Sized,

§

impl<'value, T> UnsafeUnpin for RedactedView<'value, T>

§

impl<'value, T> UnwindSafe for RedactedView<'value, T>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.