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.
§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(Sensitivity::Secret, "token", || self.0);
});
}
}
let output = Redactor::standard().redact(&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>
impl<'session> RedactionWriter<'session>
Sourcepub fn unredacted<T>(&mut self, value: &T) -> &mut Self
pub fn unredacted<T>(&mut self, value: &T) -> &mut Self
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.
Sourcepub fn unmarked<T>(&mut self, value: &T) -> &mut Self
pub fn unmarked<T>(&mut self, value: &T) -> &mut Self
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.
Sourcepub fn record<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
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.
Sourcepub fn tuple<F>(&mut self, name: &'static str, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
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.
Sourcepub fn transparent<F>(&mut self, configure: F)where
F: for<'writer> FnOnce(&mut RedactionFields<'writer, 'session>),
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.
Sourcepub fn sequence<F>(&mut self, configure: F)where
F: for<'writer> FnOnce(&mut RedactionItems<'writer, 'session>),
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.