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>
impl<T: Redact + ?Sized> Debug for RedactedView<'_, T>
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
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>
impl<T: Redact + ?Sized> Display for RedactedView<'_, T>
Source§impl<'value, T: RedactSerializeSource + ?Sized> Serialize for RedactedView<'value, T>where
T::RedactedFields<'value>: Serialize,
Available on crate feature serde only.
impl<'value, T: RedactSerializeSource + ?Sized> Serialize for RedactedView<'value, T>where
T::RedactedFields<'value>: Serialize,
serde only.Source§fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
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.