Skip to main content

RedactionWriter

Struct RedactionWriter 

Source
pub struct RedactionWriter<'session> { /* private fields */ }
Expand description

Restricted writer for one redaction operation.

Implementations use structural scopes to classify every field explicitly. The writer borrows one transaction and never publishes intermediate text.

§Type Parameters

  • 'session: Exclusive borrow of the transaction receiving this value.

§Examples

use qubit_redact::{Redact, RedactionWriter, Redactor, Sensitivity};

struct Credential(&'static str);

impl Redact for Credential {
    fn write_redacted(&self, writer: &mut RedactionWriter<'_>) {
        writer.record("Credential", |fields| {
            fields.sensitive_at_least(Sensitivity::Secret, "token", || self.0);
        });
    }
}

let output = Redactor::standard().redact_text(&Credential("raw-token"));
assert!(!output.text().as_str().contains("raw-token"));
use qubit_redact::{Redact, RedactionWriter};

struct Value;
impl Redact for Value {
    fn write_redacted(&self, writer: &mut RedactionWriter<'_>) {
        let _ = writer.redact_json_text("{\"token\":\"secret\"}");
    }
}

Implementations§

Source§

impl<'session> RedactionWriter<'session>

Source

pub fn literal(&mut self, text: &'static str)

Writes a trusted static structural literal.

§Parameters
  • text: Trusted static structure; omitted after the frame closes.
Source

pub fn unredacted<T>(&mut self, value: &T) -> &mut Self
where T: Debug + ?Sized,

Writes explicitly trusted dynamic content without redaction.

§Warning

This method is an explicit trust-boundary bypass: it never consults field policy, even when the active policy is strict. It is only for content that the caller has independently established as safe to expose. Never pass credentials, user-controlled diagnostic data, or a value whose classification depends on runtime policy; use a redaction-aware field method instead.

§Type Parameters
  • T: Possibly unsized value rendered with Debug.
§Parameters
  • value: Caller-verified safe value; formatting is skipped during inspection.
§Returns

This writer for subsequent writes.

Source

pub fn unmarked<T>(&mut self, value: &T) -> &mut Self
where T: Debug + ?Sized,

Writes a field without applying redaction policy.

§Warning

This is the semantic alias used for an intentionally unmarked field and has the same trust-boundary requirements as Self::unredacted.

§Type Parameters
  • T: Possibly unsized value rendered with Debug.
§Parameters
  • value: Caller-verified safe value with no policy classification.
§Returns

This writer for subsequent writes.

Source

pub fn record<F>(&mut self, name: &'static str, configure: F)
where F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),

Writes a named record through a field scope.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • name: Trusted static type label; an empty label emits no name.
  • configure: One-shot callback that writes through the borrowed scope.
Source

pub fn tuple<F>(&mut self, name: &'static str, configure: F)
where F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),

Writes a named tuple through a field scope.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • name: Trusted static type label; an empty label emits no name.
  • configure: One-shot callback that writes through the borrowed scope.
Source

pub fn transparent<F>(&mut self, configure: F)
where F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),

Writes exactly one field without a nominal record or tuple wrapper.

This is intended for transparent domain newtypes. The configured field still passes through the ordinary classified field operations and the same admission limits as a structured value.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • configure: One-shot callback that writes through the borrowed scope.
Source

pub fn sequence<F>(&mut self, configure: F)
where F: for<'writer> FnOnce(&mut RedactionItems<'writer, 'session>),

Writes a bracketed sequence through an item scope.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • configure: One-shot callback that writes through the borrowed scope.
Source

pub fn map<F>(&mut self, configure: F)
where F: for<'writer> FnOnce(&mut RedactionEntries<'writer, 'session>),

Writes a braced map through an entry scope.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • configure: One-shot callback that writes through the borrowed scope.
Source

pub fn variant<F>( &mut self, enum_name: &'static str, variant_name: &'static str, configure: F, )
where F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),

Writes a named enum variant through a field scope.

§Type Parameters
  • F: Callback accepting the scope for any temporary writer borrow.
§Parameters
  • enum_name: Trusted static enum label.
  • variant_name: Trusted static variant label.
  • configure: One-shot callback that writes through the borrowed scope.

Auto Trait Implementations§

§

impl<'session> !RefUnwindSafe for RedactionWriter<'session>

§

impl<'session> !Send for RedactionWriter<'session>

§

impl<'session> !Sync for RedactionWriter<'session>

§

impl<'session> !UnwindSafe for RedactionWriter<'session>

§

impl<'session> Freeze for RedactionWriter<'session>

§

impl<'session> Unpin for RedactionWriter<'session>

§

impl<'session> UnsafeUnpin for RedactionWriter<'session>

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.